|
@@ -19,6 +19,7 @@ package model
|
|
import (
|
|
import (
|
|
"bytes"
|
|
"bytes"
|
|
"fmt"
|
|
"fmt"
|
|
|
|
+ "github.com/siyuan-note/siyuan/kernel/task"
|
|
"os"
|
|
"os"
|
|
"path/filepath"
|
|
"path/filepath"
|
|
"runtime"
|
|
"runtime"
|
|
@@ -219,9 +220,10 @@ func InitConf() {
|
|
} else {
|
|
} else {
|
|
logging.LogInfof("downgraded from version [%s] to [%s]", Conf.System.KernelVersion, util.Ver)
|
|
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.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{}
|
|
@@ -779,3 +781,52 @@ func clearWorkspaceTemp() {
|
|
|
|
|
|
logging.LogInfof("cleared workspace temp")
|
|
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)
|
|
|
|
+ }
|
|
|
|
+}
|