Explorar o código

Merge remote-tracking branch 'origin/dev' into dev

Vanessa %!s(int64=2) %!d(string=hai) anos
pai
achega
2492068c4d

+ 2 - 2
app/appearance/langs/en_US.json

@@ -809,7 +809,7 @@
     "20": "Cannot be converted to heading when including sub-documents",
     "20": "Cannot be converted to heading when including sub-documents",
     "21": "Please enter the captcha",
     "21": "Please enter the captcha",
     "22": "The captcha is incorrect",
     "22": "The captcha is incorrect",
-    "23": "The data repo is corrupted due to external changes (such as using a third-party real-time synchronization disk), please reset the data repo",
+    "23": "The data repo is corrupted, please reset the data repo",
     "24": "Network timed out, please try again later",
     "24": "Network timed out, please try again later",
     "25": "The attribute name only supports English letters and digits",
     "25": "The attribute name only supports English letters and digits",
     "26": "Please initialize the data repo key first in [Settings - About - Data repo key]",
     "26": "Please initialize the data repo key first in [Settings - About - Data repo key]",
@@ -891,7 +891,7 @@
     "102": "Processing completed",
     "102": "Processing completed",
     "103": "The update installation package has been automatically downloaded in the background. When exiting, you will be asked whether to install the new version",
     "103": "The update installation package has been automatically downloaded in the background. When exiting, you will be asked whether to install the new version",
     "104": "The update installation package failed to download, please check the network connection",
     "104": "The update installation package failed to download, please check the network connection",
-    "105": "TODO",
+    "105": "Corrupted data repo have been automatically reset",
     "106": "TODO",
     "106": "TODO",
     "107": "Moving document [%s]",
     "107": "Moving document [%s]",
     "108": "Cleaning obsolete indexes...",
     "108": "Cleaning obsolete indexes...",

+ 2 - 2
app/appearance/langs/es_ES.json

@@ -809,7 +809,7 @@
     "20": "No se puede convertir en título al incluir subdocumentos",
     "20": "No se puede convertir en título al incluir subdocumentos",
     "21": "Por favor ingrese el captcha",
     "21": "Por favor ingrese el captcha",
     "22": "El captcha es incorrecto",
     "22": "El captcha es incorrecto",
-    "23": "El repositorio de datos está dañado debido a cambios externos (como el uso de un disco de sincronización en tiempo real de terceros), restablezca el repositorio de datos",
+    "23": "El repositorio de datos está dañado, reinicie el repositorio de datos",
     "24": "Se agotó el tiempo de espera de la red. Vuelva a intentarlo más tarde.",
     "24": "Se agotó el tiempo de espera de la red. Vuelva a intentarlo más tarde.",
     "25": "El nombre del atributo sólo admite letras y dígitos en inglés",
     "25": "El nombre del atributo sólo admite letras y dígitos en inglés",
     "26": "Por favor, inicialice primero la clave de repositorio de datos en [Configuración - Acerca de - Clave de repositorio de datos]",
     "26": "Por favor, inicialice primero la clave de repositorio de datos en [Configuración - Acerca de - Clave de repositorio de datos]",
@@ -891,7 +891,7 @@
     "102": "Procesamiento completado",
     "102": "Procesamiento completado",
     "103": "El paquete de instalación de la actualización se ha descargado automáticamente en segundo plano. Al salir, se le preguntará si desea instalar la nueva versión",
     "103": "El paquete de instalación de la actualización se ha descargado automáticamente en segundo plano. Al salir, se le preguntará si desea instalar la nueva versión",
     "104": "El paquete de instalación de la actualización no se pudo descargar, verifique la conexión de red",
     "104": "El paquete de instalación de la actualización no se pudo descargar, verifique la conexión de red",
-    "105": "TODO",
+    "105": "El repositorio de datos corruptos se ha restablecido automáticamente",
     "106": "TODO",
     "106": "TODO",
     "107": "Moviendo documento [%s]",
     "107": "Moviendo documento [%s]",
     "108": "Limpiando índices obsoletos...",
     "108": "Limpiando índices obsoletos...",

+ 2 - 2
app/appearance/langs/fr_FR.json

@@ -809,7 +809,7 @@
     "20": "Ne peut pas être converti en titre lorsque des sous-documents sont inclus.",
     "20": "Ne peut pas être converti en titre lorsque des sous-documents sont inclus.",
     "21": "Veuillez entrer le captcha",
     "21": "Veuillez entrer le captcha",
     "22": "Le captcha est incorrect",
     "22": "Le captcha est incorrect",
-    "23": "Le référentiel de données est endommagé en raison de modifications externes (comme l'utilisation d'un disque de synchronisation en temps réel tiers), veuillez réinitialiser le référentiel de données",
+    "23": "Le référentiel de données est corrompu, veuillez réinitialiser le référentiel de données",
     "24": "Le réseau a expiré, veuillez réessayer plus tard",
     "24": "Le réseau a expiré, veuillez réessayer plus tard",
     "25": "Le nom de l'attribut ne supporte que les lettres et les chiffres anglais.",
     "25": "Le nom de l'attribut ne supporte que les lettres et les chiffres anglais.",
     "26": "Veuillez d'abord initialiser la clé du référentiel de données dans [Paramètres - À propos - Clé du référentiel de données]",
     "26": "Veuillez d'abord initialiser la clé du référentiel de données dans [Paramètres - À propos - Clé du référentiel de données]",
@@ -891,7 +891,7 @@
     "102": "Traitement terminé",
     "102": "Traitement terminé",
     "103": "Le package d'installation de la mise à jour a été automatiquement téléchargé en arrière-plan. En quittant, il vous sera demandé si vous souhaitez installer la nouvelle version",
     "103": "Le package d'installation de la mise à jour a été automatiquement téléchargé en arrière-plan. En quittant, il vous sera demandé si vous souhaitez installer la nouvelle version",
     "104": "Le package d'installation de la mise à jour n'a pas pu être téléchargé, veuillez vérifier la connexion réseau",
     "104": "Le package d'installation de la mise à jour n'a pas pu être téléchargé, veuillez vérifier la connexion réseau",
-    "105": "TODO",
+    "105": "Le référentiel de données corrompu a été automatiquement réinitialisé",
     "106": "TODO",
     "106": "TODO",
     "107": "Déplacement du document [%s]",
     "107": "Déplacement du document [%s]",
     "108": "Nettoyage des index obsolètes...",
     "108": "Nettoyage des index obsolètes...",

+ 2 - 2
app/appearance/langs/zh_CHT.json

@@ -809,7 +809,7 @@
     "20": "包含子文檔時無法轉換為標題",
     "20": "包含子文檔時無法轉換為標題",
     "21": "請輸入驗證碼",
     "21": "請輸入驗證碼",
     "22": "驗證碼不正確",
     "22": "驗證碼不正確",
-    "23": "數據倉庫因為外部變更損壞(比如使用第三方實時同步盤),請重置數據倉庫",
+    "23": "數據倉庫已被損壞,請重置數據倉庫",
     "24": "網絡超時,請稍後再試",
     "24": "網絡超時,請稍後再試",
     "25": "屬性名僅支援英文字母和阿拉伯數字",
     "25": "屬性名僅支援英文字母和阿拉伯數字",
     "26": "請先在 [設置 - 關於 - 數據倉庫密鑰] 中初始化數據倉庫密鑰",
     "26": "請先在 [設置 - 關於 - 數據倉庫密鑰] 中初始化數據倉庫密鑰",
@@ -891,7 +891,7 @@
     "102": "處理完畢",
     "102": "處理完畢",
     "103": "已經在後台開始自動下載更新安裝包,退出時將詢問是否安裝新版本",
     "103": "已經在後台開始自動下載更新安裝包,退出時將詢問是否安裝新版本",
     "104": "更新安裝包下載失敗,請檢查網絡連接",
     "104": "更新安裝包下載失敗,請檢查網絡連接",
-    "105": "TODO",
+    "105": "已經自動重置損壞的數據倉庫",
     "106": "TODO",
     "106": "TODO",
     "107": "正在移動文檔 [%s]",
     "107": "正在移動文檔 [%s]",
     "108": "正在清理已過時的索引...",
     "108": "正在清理已過時的索引...",

+ 3 - 3
app/appearance/langs/zh_CN.json

@@ -809,7 +809,7 @@
     "20": "包含子文档时无法转换为标题",
     "20": "包含子文档时无法转换为标题",
     "21": "请输入验证码",
     "21": "请输入验证码",
     "22": "验证码不正确",
     "22": "验证码不正确",
-    "23": "数据仓库因为外部变更损坏(比如使用第三方实时同步盘),请重置数据仓库",
+    "23": "数据仓库已被损坏,请重置数据仓库",
     "24": "网络超时,请稍后再试",
     "24": "网络超时,请稍后再试",
     "25": "属性名仅支持英文字母和阿拉伯数字",
     "25": "属性名仅支持英文字母和阿拉伯数字",
     "26": "请先在 [设置 - 关于 - 数据仓库密钥] 中初始化数据仓库密钥",
     "26": "请先在 [设置 - 关于 - 数据仓库密钥] 中初始化数据仓库密钥",
@@ -862,7 +862,7 @@
     "73": "正在导入,请稍等...",
     "73": "正在导入,请稍等...",
     "74": "内核尚未完全启动 [%d%%],请稍后再试",
     "74": "内核尚未完全启动 [%d%%],请稍后再试",
     "75": "尝试访问文件失败",
     "75": "尝试访问文件失败",
-    "76": "数据文件已被其他程序锁定。(如果使用了第三方同步盘,请检查同步状态)",
+    "76": "数据文件已被其他程序锁定。",
     "77": "不可用的目录路径 [%s]",
     "77": "不可用的目录路径 [%s]",
     "78": "新老路径重复",
     "78": "新老路径重复",
     "79": "仅支持导入 Markdown 文档",
     "79": "仅支持导入 Markdown 文档",
@@ -891,7 +891,7 @@
     "102": "处理完毕",
     "102": "处理完毕",
     "103": "已经在后台开始自动下载更新安装包,退出时将询问是否安装新版本",
     "103": "已经在后台开始自动下载更新安装包,退出时将询问是否安装新版本",
     "104": "更新安装包下载失败,请检查网络连接",
     "104": "更新安装包下载失败,请检查网络连接",
-    "105": "TODO",
+    "105": "已经自动重置损坏的数据仓库",
     "106": "TODO",
     "106": "TODO",
     "107": "正在移动文档 [%s]",
     "107": "正在移动文档 [%s]",
     "108": "正在清理已过时的索引...",
     "108": "正在清理已过时的索引...",

+ 1 - 1
kernel/go.mod

@@ -37,7 +37,7 @@ require (
 	github.com/patrickmn/go-cache v2.1.0+incompatible
 	github.com/patrickmn/go-cache v2.1.0+incompatible
 	github.com/qiniu/go-sdk/v7 v7.13.0
 	github.com/qiniu/go-sdk/v7 v7.13.0
 	github.com/radovskyb/watcher v1.0.7
 	github.com/radovskyb/watcher v1.0.7
-	github.com/siyuan-note/dejavu v0.0.0-20221008180903-80366e53821a
+	github.com/siyuan-note/dejavu v0.0.0-20221009014342-57351eb27c75
 	github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75
 	github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75
 	github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da
 	github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da
 	github.com/siyuan-note/filelock v0.0.0-20221007163134-7e64809023ef
 	github.com/siyuan-note/filelock v0.0.0-20221007163134-7e64809023ef

+ 2 - 4
kernel/go.sum

@@ -345,10 +345,8 @@ github.com/shurcooL/reactions v0.0.0-20181006231557-f2e0b4ca5b82/go.mod h1:TCR1l
 github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
 github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
 github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4=
 github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4=
 github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw=
 github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw=
-github.com/siyuan-note/dejavu v0.0.0-20220930021019-e62491947339 h1:jePYjiGBPa5Qs8bCdlPDrRzfNxr0FJ+rQYv/d6H5p8A=
-github.com/siyuan-note/dejavu v0.0.0-20220930021019-e62491947339/go.mod h1:Y+bg0j0Z7C66oJWPPYMs+wZuFeiTRWhh2aLkqctJFKk=
-github.com/siyuan-note/dejavu v0.0.0-20221008180903-80366e53821a h1:5zn/SFVvih7nwr8bRB9qeZ9NHfjSUA9dneEMqNzsPps=
-github.com/siyuan-note/dejavu v0.0.0-20221008180903-80366e53821a/go.mod h1:Y+bg0j0Z7C66oJWPPYMs+wZuFeiTRWhh2aLkqctJFKk=
+github.com/siyuan-note/dejavu v0.0.0-20221009014342-57351eb27c75 h1:4aExF0IlFsBj+54knKzWfr+9FVui4lzua/fwXqjKmjQ=
+github.com/siyuan-note/dejavu v0.0.0-20221009014342-57351eb27c75/go.mod h1:Y+bg0j0Z7C66oJWPPYMs+wZuFeiTRWhh2aLkqctJFKk=
 github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 h1:Bi7/7f29LW+Fm0cHc0J1NO1cZqyJwljSWVmfOqVZgaE=
 github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 h1:Bi7/7f29LW+Fm0cHc0J1NO1cZqyJwljSWVmfOqVZgaE=
 github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw=
 github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw=
 github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da h1:/jNhl7LC+9BhkWvNxuJDdsNfA/2wvfuj9mqWx4CbV90=
 github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da h1:/jNhl7LC+9BhkWvNxuJDdsNfA/2wvfuj9mqWx4CbV90=

+ 6 - 0
kernel/model/assets_watcher.go

@@ -19,9 +19,11 @@
 package model
 package model
 
 
 import (
 import (
+	"os"
 	"path/filepath"
 	"path/filepath"
 	"time"
 	"time"
 
 
+	"github.com/88250/gulu"
 	"github.com/fsnotify/fsnotify"
 	"github.com/fsnotify/fsnotify"
 	"github.com/siyuan-note/logging"
 	"github.com/siyuan-note/logging"
 	"github.com/siyuan-note/siyuan/kernel/cache"
 	"github.com/siyuan-note/siyuan/kernel/cache"
@@ -89,6 +91,10 @@ func watchAssets() {
 		}
 		}
 	}()
 	}()
 
 
+	if !gulu.File.IsDir(assetsDir) {
+		os.MkdirAll(assetsDir, 0755)
+	}
+
 	if err = assetsWatcher.Add(assetsDir); err != nil {
 	if err = assetsWatcher.Add(assetsDir); err != nil {
 		logging.LogErrorf("add assets watcher for folder [%s] failed: %s", assetsDir, err)
 		logging.LogErrorf("add assets watcher for folder [%s] failed: %s", assetsDir, err)
 	}
 	}

+ 8 - 2
kernel/model/repository.go

@@ -682,15 +682,21 @@ func indexRepoBeforeCloudSync(repo *dejavu.Repo) (err error) {
 		eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar,
 		eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar,
 	})
 	})
 	if errors.Is(err, dejavu.ErrNotFoundObject) {
 	if errors.Is(err, dejavu.ErrNotFoundObject) {
+		logging.LogWarnf("data repo is corrupted, try to reset it")
 		resetErr := os.RemoveAll(filepath.Join(repo.Path))
 		resetErr := os.RemoveAll(filepath.Join(repo.Path))
 		if nil != resetErr {
 		if nil != resetErr {
-			logging.LogErrorf("reset data repo failed: %s", resetErr)
+			logging.LogErrorf("remove data repo failed: %s", resetErr)
 			return
 			return
 		}
 		}
-		logging.LogWarnf("data repo has been reset caused by not found object")
 		index, err = repo.Index("[Sync] Cloud sync", map[string]interface{}{
 		index, err = repo.Index("[Sync] Cloud sync", map[string]interface{}{
 			eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar,
 			eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar,
 		})
 		})
+		logging.LogWarnf("data repo has been reset")
+
+		go func() {
+			time.Sleep(5 * time.Second)
+			util.PushMsg(Conf.Language(105), 5000)
+		}()
 	}
 	}
 
 
 	if nil != err {
 	if nil != err {

+ 42 - 1
kernel/model/updater.go

@@ -26,6 +26,8 @@ import (
 	"path"
 	"path"
 	"path/filepath"
 	"path/filepath"
 	"runtime"
 	"runtime"
+	"strconv"
+	"strings"
 	"sync"
 	"sync"
 	"time"
 	"time"
 
 
@@ -214,6 +216,45 @@ func GetAnnouncements() (ret []*Announcement) {
 	}
 	}
 	return
 	return
 }
 }
+func ver2num(a string) int {
+	var version string
+	var suffixpos int
+	var suffixStr string
+	var suffix string
+	a = strings.Trim(a, " ")
+	if strings.Contains(a, "alpha") {
+		suffixpos = strings.Index(a, "-alpha")
+		version = a[0:suffixpos]
+		suffixStr = a[suffixpos+6 : len(a)]
+		suffix = "0" + fmt.Sprintf("%03s", suffixStr)
+	} else if strings.Contains(a, "beta") {
+		suffixpos = strings.Index(a, "-beta")
+		version = a[0:suffixpos]
+		suffixStr = a[suffixpos+5 : len(a)]
+		suffix = "1" + fmt.Sprintf("%03s", suffixStr)
+	} else {
+		version = a
+		suffix = "5000"
+	}
+	split := strings.Split(version, ".")
+	var verArr []string
+
+	verArr = append(verArr, "1")
+	var tmp string
+	for i := 0; i < 3; i++ {
+		if i < len(split) {
+			tmp = split[i]
+		} else {
+			tmp = "0"
+		}
+		verArr = append(verArr, fmt.Sprintf("%04s", tmp))
+	}
+	verArr = append(verArr, suffix)
+
+	ver := strings.Join(verArr, "")
+	verNum, _ := strconv.Atoi(ver)
+	return verNum
+}
 
 
 func CheckUpdate(showMsg bool) {
 func CheckUpdate(showMsg bool) {
 	if !showMsg {
 	if !showMsg {
@@ -229,7 +270,7 @@ func CheckUpdate(showMsg bool) {
 	release := result["release"].(string)
 	release := result["release"].(string)
 	var msg string
 	var msg string
 	var timeout int
 	var timeout int
-	if ver == util.Ver {
+	if ver2num(ver) <= ver2num(util.Ver) {
 		msg = Conf.Language(10)
 		msg = Conf.Language(10)
 		timeout = 3000
 		timeout = 3000
 	} else {
 	} else {