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

This commit is contained in:
Daniel 2024-02-06 21:30:36 +08:00
parent 7269b646e7
commit 248bf80415
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
8 changed files with 35 additions and 27 deletions

View file

@ -1157,7 +1157,6 @@
"task.history.database.index.commit": "Execute history database index commit", "task.history.database.index.commit": "Execute history database index commit",
"task.database.index.embedBlock": "Execute database index embed block", "task.database.index.embedBlock": "Execute database index embed block",
"task.reload.ui": "Execute reload UI", "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.full": "Execute asset database rebuild index",
"task.asset.database.index.commit": "Execute asset database index commit" "task.asset.database.index.commit": "Execute asset database index commit"
}, },
@ -1408,6 +1407,7 @@
"229": "Deleting cloud storage unreferenced snapshots...", "229": "Deleting cloud storage unreferenced snapshots...",
"230": "Deleting cloud storage unreferenced check indexes...", "230": "Deleting cloud storage unreferenced check indexes...",
"231": "Deleting unreferenced data objects in cloud storage...", "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..."
} }
} }

View file

@ -1157,7 +1157,6 @@
"task.history.database.index.commit": "Ejecutar la confirmación del índice de la base de datos del historial", "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.database.index.embedBlock": "Ejecutar bloque de incrustación de índice de base de datos",
"task.reload.ui": "IU de recarga de tareas", "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.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" "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...", "229": "Eliminando instantáneas sin referencia del almacenamiento en la nube...",
"230": "Eliminando índices de verificación 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...", "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..."
} }
} }

View file

@ -1157,7 +1157,6 @@
"task.history.database.index.commit": "Effectuer la validation de l'index de la base de données d'historique", "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.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.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.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" "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...", "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...", "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...", "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..."
} }
} }

View file

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

View file

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

View file

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

View file

@ -190,7 +190,10 @@ func syncData(exit, byHand bool) {
if exit { if exit {
ExitSyncSucc = 0 ExitSyncSucc = 0
logging.LogInfof("sync before exit") 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() now := util.CurrentTimeMillis()

View file

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