🎨 笔记本配置文件缺失时将笔记本文件夹移动到 工作空间/corrupted/
文件夹下 Fix https://github.com/siyuan-note/siyuan/issues/5853
This commit is contained in:
parent
dc70850582
commit
38c70f13a4
1 changed files with 15 additions and 5 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue