🎨 Automatically move corrupted notebook folders to the corrupted folder https://github.com/siyuan-note/siyuan/issues/9202

This commit is contained in:
Daniel 2023-09-17 10:24:40 +08:00
parent 2130eea4a5
commit d8ba2cded1
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -112,7 +112,18 @@ func ListNotebooks() (ret []*Box, err error) {
boxDirPath := filepath.Join(util.DataDir, dir.Name()) boxDirPath := filepath.Join(util.DataDir, dir.Name())
boxConfPath := filepath.Join(boxDirPath, ".siyuan", "conf.json") boxConfPath := filepath.Join(boxDirPath, ".siyuan", "conf.json")
if !gulu.File.IsExist(boxConfPath) { if !gulu.File.IsExist(boxConfPath) {
// Automatically move corrupted notebook folders to the corrupted folder https://github.com/siyuan-note/siyuan/issues/9202
logging.LogWarnf("found a corrupted box [%s]", boxDirPath) logging.LogWarnf("found a corrupted box [%s]", boxDirPath)
to := filepath.Join(util.WorkspaceDir, "corrupted", time.Now().Format("2006-01-02-150405"), dir.Name())
if copyErr := filelock.Copy(boxDirPath, to); nil != copyErr {
logging.LogErrorf("copy corrupted notebook dir [%s] failed: %s", boxDirPath, copyErr)
continue
}
if removeErr := filelock.Remove(boxDirPath); nil != removeErr {
logging.LogErrorf("remove corrupted data file [%s] failed: %s", boxDirPath, removeErr)
continue
}
util.ReloadUI()
continue continue
} }