Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: 笔记本配置文件缺失时将笔记本文件夹移动到 `工作空间/corrupted/` 文件夹下 Fix https://github.com/siyuan-note/siyuan/issues/5853

Liang Ding38c70f13a4f3
diff --git a/kernel/model/box.go b/kernel/model/box.go
index 7b1ee0b44d..fab24fdff4 100644
--- a/kernel/model/box.go
+++ b/kernel/model/box.go
@@ -83,15 +83,25 @@ func ListNotebooks() (ret []*Box, err error) {
}
boxConf := conf.NewBoxConf()
- boxConfPath := filepath.Join(util.DataDir, dir.Name(), ".siyuan", "conf.json")
+ boxDirPath := filepath.Join(util.DataDir, dir.Name())
+ boxConfPath := filepath.Join(boxDirPath, ".siyuan", "conf.json")
if !gulu.File.IsExist(boxConfPath) {
+ filelock.ReleaseAllFileLocks()
if IsUserGuide(dir.Name()) {
- filelock.ReleaseAllFileLocks()
- os.RemoveAll(filepath.Join(util.DataDir, dir.Name()))
- logging.LogWarnf("not found user guid box conf [%s], removed it", boxConfPath)
+ os.RemoveAll(boxDirPath)
continue
}
- logging.LogWarnf("not found box conf [%s], recreate it", boxConfPath)
+ to := filepath.Join(util.WorkspaceDir, "corrupted", time.Now().Format("2006-01-02-150405"), dir.Name())
+ if renameErr := gulu.File.CopyDir(boxDirPath, to); nil != renameErr {
+ logging.LogErrorf("copy corrupted box [%s] failed: %s", boxDirPath, renameErr)
+ continue
+ }
+ if removeErr := os.RemoveAll(boxDirPath); nil != removeErr {
+ logging.LogErrorf("remove corrupted box [%s] failed: %s", boxDirPath, removeErr)
+ continue
+ }
+ logging.LogWarnf("moved corrupted box [%s] to [%s]", boxDirPath, to)
+ continue
} else {
data, readErr := filelock.NoLockFileRead(boxConfPath)
if nil != readErr {