ソースを参照

:art: Close the user guide when exiting Fix https://github.com/siyuan-note/siyuan/issues/10322

Daniel 1 年間 前
コミット
248bf80415

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

@@ -1157,7 +1157,6 @@
     "task.history.database.index.commit": "Execute history database index commit",
     "task.database.index.embedBlock": "Execute database index embed block",
     "task.reload.ui": "Execute reload UI",
-    "task.upgrade.userGuide": "Execute upgrade user guide",
     "task.asset.database.index.full": "Execute asset database rebuild index",
     "task.asset.database.index.commit": "Execute asset database index commit"
   },
@@ -1408,6 +1407,7 @@
     "229": "Deleting cloud storage unreferenced snapshots...",
     "230": "Deleting cloud storage unreferenced check indexes...",
     "231": "Deleting unreferenced data objects in cloud storage...",
-    "232": "The cloud data storage has been purged. [%d] snapshots and [%d] data objects have been deleted, and a total of [%s] disk space has been released"
+    "232": "The cloud data storage has been purged. [%d] snapshots and [%d] data objects have been deleted, and a total of [%s] disk space has been released",
+    "233": "Closing user guide..."
   }
 }

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

@@ -1157,7 +1157,6 @@
     "task.history.database.index.commit": "Ejecutar la confirmación del índice de la base de datos del historial",
     "task.database.index.embedBlock": "Ejecutar bloque de incrustación de índice de base de datos",
     "task.reload.ui": "IU de recarga de tareas",
-    "task.upgrade.userGuide": "Ejecutar la guía de usuario de actualización",
     "task.asset.database.index.full": "Ejecutar índice de reconstrucción de base de datos de activos",
     "task.asset.database.index.commit": "Ejecutar confirmación del índice de la base de datos de activos"
   },
@@ -1408,6 +1407,7 @@
     "229": "Eliminando instantáneas sin referencia del almacenamiento en la nube...",
     "230": "Eliminando índices de verificación sin referencia del almacenamiento en la nube...",
     "231": "Eliminar objetos de datos no referenciados en el almacenamiento en la nube...",
-    "232": "Se ha eliminado el almacenamiento de datos en la nube. Se han eliminado [%d] instantáneas y [%d] objetos de datos, y se ha liberado un total de [%s] espacio en disco"
+    "232": "Se ha eliminado el almacenamiento de datos en la nube. Se han eliminado [%d] instantáneas y [%d] objetos de datos, y se ha liberado un total de [%s] espacio en disco",
+    "233": "Cerrando la guía del usuario..."
   }
 }

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

@@ -1157,7 +1157,6 @@
     "task.history.database.index.commit": "Effectuer la validation de l'index de la base de données d'historique",
     "task.database.index.embedBlock": "Exécuter le bloc d'intégration d'index de base de données",
     "task.reload.ui": "Interface utilisateur de rechargement de tâche",
-    "task.upgrade.userGuide": "Mise à niveau de la tâche de guide utilisateur",
     "task.asset.database.index.full": "Exécuter l'index de reconstruction de la base de données d'actifs",
     "task.asset.database.index.commit": "Exécuter la validation de l'index de la base de données des actifs"
   },
@@ -1408,6 +1407,7 @@
     "229": "Suppression des instantanés non référencés du stockage cloud...",
     "230": "Suppression des index de vérification non référencés du stockage cloud...",
     "231": "Suppression des objets de données non référencés dans le stockage cloud...",
-    "232": "Le stockage de données cloud a été purgé. [%d] instantanés et [%d] objets de données ont été supprimés, et un total de [%s] espace disque a été libéré"
+    "232": "Le stockage de données cloud a été purgé. [%d] instantanés et [%d] objets de données ont été supprimés, et un total de [%s] espace disque a été libéré",
+    "233": "Fermeture du guide de l'utilisateur..."
   }
 }

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

@@ -1157,7 +1157,6 @@
     "task.history.database.index.commit": "執行歷史資料庫索引提交",
     "task.database.index.embedBlock": "執行資料庫索引嵌入塊",
     "task.reload.ui": "執行重載界面",
-    "task.upgrade.userGuide": "執行升級用戶指南",
     "task.asset.database.index.full": "執行資源文件數據庫重建索引",
     "task.asset.database.index.commit": "執行資源文件數據庫索引提交"
   },
@@ -1408,6 +1407,7 @@
     "229": "正在刪除雲端儲存未引用快照...",
     "230": "正在刪除雲端儲存未引用校驗快照...",
     "231": "正在刪除雲端儲存未引用資料物件...",
-    "232": "雲端資料儲存清理完畢,已刪除 [%d] 個快照和 [%d] 個資料對象,共釋放 [%s] 磁碟空間"
+    "232": "雲端資料儲存清理完畢,已刪除 [%d] 個快照和 [%d] 個資料對象,共釋放 [%s] 磁碟空間",
+    "233": "正在關閉使用者指南..."
   }
 }

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

@@ -1157,7 +1157,6 @@
     "task.history.database.index.commit": "执行历史数据库索引提交",
     "task.database.index.embedBlock": "执行数据库索引嵌入块",
     "task.reload.ui": "执行重载界面",
-    "task.upgrade.userGuide": "执行升级用户指南",
     "task.asset.database.index.full": "执行资源文件数据库重建索引",
     "task.asset.database.index.commit": "执行资源文件数据库索引提交"
   },
@@ -1408,6 +1407,7 @@
     "229": "正在删除云端存储未引用快照...",
     "230": "正在删除云端存储未引用校验快照...",
     "231": "正在删除云端存储未引用数据对象...",
-    "232": "云端数据存储清理完毕,已删除 [%d] 个快照和 [%d] 个数据对象,共释放 [%s] 磁盘空间"
+    "232": "云端数据存储清理完毕,已删除 [%d] 个快照和 [%d] 个数据对象,共释放 [%s] 磁盘空间",
+    "233": "正在关闭用户指南..."
   }
 }

+ 21 - 15
kernel/model/conf.go

@@ -40,7 +40,6 @@ import (
 	"github.com/siyuan-note/logging"
 	"github.com/siyuan-note/siyuan/kernel/conf"
 	"github.com/siyuan-note/siyuan/kernel/sql"
-	"github.com/siyuan-note/siyuan/kernel/task"
 	"github.com/siyuan-note/siyuan/kernel/treenode"
 	"github.com/siyuan-note/siyuan/kernel/util"
 	"golang.org/x/mod/semver"
@@ -284,7 +283,6 @@ func InitConf() {
 
 		Conf.System.KernelVersion = util.Ver
 		Conf.System.IsInsider = util.IsInsider
-		task.AppendTask(task.UpgradeUserGuide, upgradeUserGuide)
 	}
 	if nil == Conf.System.NetworkProxy {
 		Conf.System.NetworkProxy = &conf.NetworkProxy{}
@@ -533,7 +531,6 @@ var exitLock = sync.Mutex{}
 func Close(force bool, execInstallPkg int) (exitCode int) {
 	exitLock.Lock()
 	defer exitLock.Unlock()
-	util.IsExiting.Store(true)
 
 	logging.LogInfof("exiting kernel [force=%v, execInstallPkg=%d]", force, execInstallPkg)
 	util.PushMsg(Conf.Language(95), 10000*60)
@@ -550,6 +547,10 @@ func Close(force bool, execInstallPkg int) (exitCode int) {
 		}
 	}
 
+	// Close the user guide when exiting https://github.com/siyuan-note/siyuan/issues/10322
+	closeUserGuide()
+
+	util.IsExiting.Store(true)
 	waitSecondForExecInstallPkg := false
 	if !skipNewVerInstallPkg() {
 		if newVerInstallPkgPath := getNewVerInstallPkgPath(); "" != newVerInstallPkgPath {
@@ -945,7 +946,7 @@ func clearWorkspaceTemp() {
 	logging.LogInfof("cleared workspace temp")
 }
 
-func upgradeUserGuide() {
+func closeUserGuide() {
 	defer logging.Recover()
 
 	dirs, err := os.ReadDir(util.DataDir)
@@ -976,10 +977,20 @@ func upgradeUserGuide() {
 		data, readErr := filelock.ReadFile(boxConfPath)
 		if nil != readErr {
 			logging.LogErrorf("read box conf [%s] failed: %s", boxConfPath, readErr)
+			if removeErr := filelock.Remove(boxDirPath); nil != removeErr {
+				logging.LogErrorf("remove corrupted user guide box [%s] failed: %s", boxDirPath, removeErr)
+			} else {
+				logging.LogInfof("removed corrupted user guide box [%s]", boxDirPath)
+			}
 			continue
 		}
 		if readErr = gulu.JSON.UnmarshalJSON(data, boxConf); nil != readErr {
 			logging.LogErrorf("parse box conf [%s] failed: %s", boxConfPath, readErr)
+			if removeErr := filelock.Remove(boxDirPath); nil != removeErr {
+				logging.LogErrorf("remove corrupted user guide box [%s] failed: %s", boxDirPath, removeErr)
+			} else {
+				logging.LogInfof("removed corrupted user guide box [%s]", boxDirPath)
+			}
 			continue
 		}
 
@@ -987,19 +998,14 @@ func upgradeUserGuide() {
 			continue
 		}
 
-		logging.LogInfof("upgrading user guide box [%s]", boxID)
+		msgId := util.PushMsg(Conf.language(233), 30000)
 		unindex(boxID)
-
-		if err = filelock.Remove(boxDirPath); nil != err {
-			return
+		if removeErr := filelock.Remove(boxDirPath); nil != removeErr {
+			logging.LogErrorf("remove corrupted user guide box [%s] failed: %s", boxDirPath, removeErr)
 		}
-		p := filepath.Join(util.WorkingDir, "guide", boxID)
-		if err = filelock.Copy(p, boxDirPath); nil != err {
-			return
-		}
-
-		index(boxID)
-		logging.LogInfof("upgraded user guide box [%s]", boxID)
+		sql.WaitForWritingDatabase()
+		util.PushClearMsg(msgId)
+		logging.LogInfof("closed user guide box [%s]", boxID)
 	}
 }
 

+ 4 - 1
kernel/model/sync.go

@@ -190,7 +190,10 @@ func syncData(exit, byHand bool) {
 	if exit {
 		ExitSyncSucc = 0
 		logging.LogInfof("sync before exit")
-		util.PushMsg(Conf.Language(81), 1000*60*15)
+		msgId := util.PushMsg(Conf.Language(81), 1000*60*15)
+		defer func() {
+			util.PushClearMsg(msgId)
+		}()
 	}
 
 	now := util.CurrentTimeMillis()

+ 0 - 1
kernel/task/queue.go

@@ -97,7 +97,6 @@ const (
 	HistoryDatabaseIndexCommit      = "task.history.database.index.commit" // 历史数据库索引提交
 	DatabaseIndexEmbedBlock         = "task.database.index.embedBlock"     // 数据库索引嵌入块
 	ReloadUI                        = "task.reload.ui"                     // 重载 UI
-	UpgradeUserGuide                = "task.upgrade.userGuide"             // 升级用户指南文档笔记本
 	AssetContentDatabaseIndexFull   = "task.asset.database.index.full"     // 资源文件数据库重建索引
 	AssetContentDatabaseIndexCommit = "task.asset.database.index.commit"   // 资源文件数据库索引提交
 )