From d8ba2cded1be0e6db315618d1c72a84d349c1ea6 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sun, 17 Sep 2023 10:24:40 +0800 Subject: [PATCH] :art: Automatically move corrupted notebook folders to the corrupted folder https://github.com/siyuan-note/siyuan/issues/9202 --- kernel/model/box.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kernel/model/box.go b/kernel/model/box.go index 3e240610a..0f728a97a 100644 --- a/kernel/model/box.go +++ b/kernel/model/box.go @@ -112,7 +112,18 @@ func ListNotebooks() (ret []*Box, err error) { boxDirPath := filepath.Join(util.DataDir, dir.Name()) boxConfPath := filepath.Join(boxDirPath, ".siyuan", "conf.json") 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) + 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 }