mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-10 01:04:21 +01:00
🎨 Close the user guide when exiting Fix https://github.com/siyuan-note/siyuan/issues/10322
This commit is contained in:
parent
7269b646e7
commit
248bf80415
8 changed files with 35 additions and 27 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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" // 资源文件数据库索引提交
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue