mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-15 13:18:51 +01:00
🐛 更新版本后自动打开最新版的用户指南重复 https://github.com/siyuan-note/siyuan/issues/7517
This commit is contained in:
parent
dd5336b9b1
commit
76aef4689b
8 changed files with 66 additions and 6 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue