🎨 文件系统读取或写入失败时退出内核 https://github.com/siyuan-note/siyuan/issues/7707

This commit is contained in:
Liang Ding 2023-03-19 09:59:16 +08:00
parent 5f6d1eac9a
commit c8cef8f455
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
5 changed files with 16 additions and 20 deletions

View file

@ -325,7 +325,7 @@ func InitBlockTree(force bool) {
entries, err := os.ReadDir(util.BlockTreePath)
if nil != err {
logging.LogErrorf("read block tree dir failed: %s", err)
os.Exit(logging.ExitCodeBlockTreeErr)
os.Exit(logging.ExitCodeFileSysErr)
return
}
@ -342,7 +342,7 @@ func InitBlockTree(force bool) {
fh, err = os.OpenFile(p, os.O_RDWR, 0644)
if nil != err {
logging.LogErrorf("open block tree file failed: %s", err)
os.Exit(logging.ExitCodeBlockTreeErr)
os.Exit(logging.ExitCodeFileSysErr)
return
}
@ -351,7 +351,7 @@ func InitBlockTree(force bool) {
fh.Close()
if nil != err {
logging.LogErrorf("read block tree failed: %s", err)
os.Exit(logging.ExitCodeBlockTreeErr)
os.Exit(logging.ExitCodeFileSysErr)
return
}
@ -361,7 +361,7 @@ func InitBlockTree(force bool) {
if err = os.RemoveAll(util.BlockTreePath); nil != err {
logging.LogErrorf("removed corrupted block tree failed: %s", err)
}
os.Exit(logging.ExitCodeBlockTreeErr)
os.Exit(logging.ExitCodeFileSysErr)
return
}
@ -410,7 +410,7 @@ func SaveBlockTree(force bool) {
data, err := msgpack.Marshal(slice.data)
if nil != err {
logging.LogErrorf("marshal block tree failed: %s", err)
os.Exit(logging.ExitCodeBlockTreeErr)
os.Exit(logging.ExitCodeFileSysErr)
return false
}
slice.m.Unlock()
@ -418,7 +418,7 @@ func SaveBlockTree(force bool) {
p := filepath.Join(util.BlockTreePath, key.(string)) + ".msgpack"
if err = gulu.File.WriteFileSafer(p, data, 0644); nil != err {
logging.LogErrorf("write block tree failed: %s", err)
os.Exit(logging.ExitCodeBlockTreeErr)
os.Exit(logging.ExitCodeFileSysErr)
return false
}