🐛 更新版本后自动打开最新版的用户指南重复 https://github.com/siyuan-note/siyuan/issues/7517

This commit is contained in:
Liang Ding 2023-03-07 14:50:21 +08:00
parent dd5336b9b1
commit 76aef4689b
No known key found for this signature in database
GPG Key ID: 136F30F901A2231D
8 changed files with 66 additions and 6 deletions

View File

@ -908,7 +908,8 @@
"task.history.generateDoc": "Execute GenerateDoc History",
"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.reload.ui": "Execute reload UI",
"task.upgrade.userGuide": "Execute upgrade user guide"
},
"_trayMenu": {
"showWindow": "Show Window",

View File

@ -908,7 +908,8 @@
"task.history.generateDoc": "Ejecutar Historial GenerateDoc",
"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.reload.ui": "IU de recarga de tareas",
"task.upgrade.userGuide": "Ejecutar la guía de usuario de actualización",
},
"_trayMenu": {
"showWindow": "Mostrar ventana",

View File

@ -908,7 +908,8 @@
"task.history.generateDoc": "Exécuter l'historique de GenerateDoc",
"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.reload.ui": "Interface utilisateur de rechargement de tâche",
"task.upgrade.userGuide": "Mise à niveau de la tâche de guide utilisateur",
},
"_trayMenu": {
"showWindow": "Afficher la fenêtre principale",

View File

@ -908,7 +908,8 @@
"task.history.generateDoc": "執行生成文件歷史",
"task.history.database.index.commit": "執行歷史數據庫索引提交",
"task.database.index.embedBlock": "執行數據庫索引嵌入塊",
"task.reload.ui": "執行重載界面"
"task.reload.ui": "執行重載界面",
"task.upgrade.userGuide": "執行升級用戶指南"
},
"_trayMenu": {
"showWindow": "顯示主窗口",

View File

@ -908,7 +908,8 @@
"task.history.generateDoc": "执行生成文件历史",
"task.history.database.index.commit": "执行历史数据库索引提交",
"task.database.index.embedBlock": "执行数据库索引嵌入块",
"task.reload.ui": "执行重载界面"
"task.reload.ui": "执行重载界面",
"task.upgrade.userGuide": "执行升级用户指南"
},
"_trayMenu": {
"showWindow": "显示主窗口",

View File

@ -19,6 +19,7 @@ package model
import (
"bytes"
"fmt"
"github.com/siyuan-note/siyuan/kernel/task"
"os"
"path/filepath"
"runtime"
@ -219,9 +220,10 @@ func InitConf() {
} else {
logging.LogInfof("downgraded from version [%s] to [%s]", Conf.System.KernelVersion, util.Ver)
}
Conf.OpenHelp = Conf.System.KernelVersion != util.Ver
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{}
@ -779,3 +781,52 @@ func clearWorkspaceTemp() {
logging.LogInfof("cleared workspace temp")
}
func upgradeUserGuide() {
dirs, err := os.ReadDir(util.DataDir)
if nil != err {
logging.LogErrorf("read dir [%s] failed: %s", util.DataDir, err)
return
}
for _, dir := range dirs {
if !IsUserGuide(dir.Name()) {
continue
}
boxID := dir.Name()
boxDirPath := filepath.Join(util.DataDir, boxID)
boxConf := conf.NewBoxConf()
boxConfPath := filepath.Join(boxDirPath, ".siyuan", "conf.json")
if !gulu.File.IsExist(boxConfPath) {
logging.LogWarnf("found a corrupted box [%s]", boxDirPath)
continue
}
data, readErr := filelock.ReadFile(boxConfPath)
if nil != readErr {
logging.LogErrorf("read box conf [%s] failed: %s", boxConfPath, readErr)
continue
}
if readErr = gulu.JSON.UnmarshalJSON(data, boxConf); nil != readErr {
logging.LogErrorf("parse box conf [%s] failed: %s", boxConfPath, readErr)
continue
}
if boxConf.Closed {
continue
}
unindex(boxID)
if err = filelock.Remove(boxDirPath); nil != err {
return
}
p := filepath.Join(util.WorkingDir, "guide", boxID)
if err = filelock.Copy(p, boxDirPath); nil != err {
return
}
index(boxID)
}
}

View File

@ -93,6 +93,7 @@ const (
HistoryDatabaseIndexCommit = "task.history.database.index.commit" // 历史数据库索引提交
DatabaseIndexEmbedBlock = "task.database.index.embedBlock" // 数据库索引嵌入块
ReloadUI = "task.reload.ui" // 重载 UI
UpgradeUserGuide = "task.upgrade.userGuide" // 升级用户指南文档笔记本
)
// uniqueActions 描述了唯一的任务,即队列中只能存在一个在执行的任务。

View File

@ -194,6 +194,9 @@ func SizeOfDirectory(path string) (size int64, err error) {
func DataSize() (dataSize, assetsSize int64) {
filepath.Walk(DataDir, func(path string, info os.FileInfo, err error) error {
if nil != err {
if os.IsNotExist(err) {
return nil
}
logging.LogErrorf("size of data failed: %s", err)
return io.EOF
}