An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: 使用第三方同步盘时弹出提示并退出内核 https://github.com/siyuan-note/siyuan/issues/7683
Liang Ding597107674975
diff --git a/kernel/filesys/tree.go b/kernel/filesys/tree.goindex 64f4532508..2b1178b654 100644--- a/kernel/filesys/tree.go+++ b/kernel/filesys/tree.go@@ -41,6 +41,10 @@ func LoadTree(boxID, p string, luteEngine *lute.Lute) (ret *parse.Tree, err errodata, err := filelock.ReadFile(filePath)if nil != err {logging.LogErrorf("load tree [%s] failed: %s", p, err)+ if errors.Is(err, filelock.ErrUnableAccessFile) {+ os.Exit(util.ExitCodeFileSysInconsistent)+ return+ }return}@@ -92,6 +96,10 @@ func LoadTreeByData(data []byte, boxID, p string, luteEngine *lute.Lute) (ret *p}} else {logging.LogWarnf("read parent tree data [%s] failed: %s", parentAbsPath, readErr)+ if errors.Is(readErr, filelock.ErrUnableAccessFile) {+ os.Exit(util.ExitCodeFileSysInconsistent)+ return+ }}hPathBuilder.WriteString("Untitled/")continuediff --git a/kernel/sql/queue.go b/kernel/sql/queue.goindex 2c9d04f788..d4b2897463 100644--- a/kernel/sql/queue.go+++ b/kernel/sql/queue.go@@ -130,7 +130,7 @@ func FlushQueue() {context["total"] = groupOpsTotal[op.action]if err = execOp(op, tx, context); nil != err {tx.Rollback()- logging.LogErrorf("queue operation failed: %s", err)+ logging.LogErrorf("queue operation [%s] failed: %s", op.action, err)continue}diff --git a/kernel/util/runtime.go b/kernel/util/runtime.goindex 6ee85eb046..140c007b6d 100644--- a/kernel/util/runtime.go+++ b/kernel/util/runtime.go@@ -17,6 +17,7 @@package utilimport (+ "bytes""fmt""math/rand""os"@@ -137,7 +138,12 @@ func CheckFileSysStatus() {reportFileSysFatalError := func(err error) {stack := debug.Stack()- logging.LogErrorf("check file system status failed: %s, %s", err, stack)+ output := string(stack)+ if 5 < strings.Count(output, "\n") {+ lines := strings.Split(output, "\n")+ output = strings.Join(lines[5:], "\n")+ }+ logging.LogErrorf("check file system status failed: %s, %s", err, output)os.Exit(ExitCodeFileSysInconsistent)}@@ -179,26 +185,26 @@ func CheckFileSysStatus() {time.Sleep(time.Second)for j := 0; j < 32; j++ {- f, err := os.Open(tmp)- if nil != err {+ renamed := tmp + "_renamed"+ if err = os.Rename(tmp, renamed); nil != err {reportFileSysFatalError(err)break}- if err = f.Close(); nil != err {+ time.Sleep(100 * time.Millisecond)++ f, err := os.Open(renamed)+ if nil != err {reportFileSysFatalError(err)break}- time.Sleep(200 * time.Millisecond)-- if err = os.Rename(tmp, tmp+"_renamed"); nil != err {+ if err = f.Close(); nil != err {reportFileSysFatalError(err)break}- time.Sleep(200 * time.Millisecond)- if err = os.Rename(tmp+"_renamed", tmp); nil != err {+ if err = os.Rename(renamed, tmp); nil != err {reportFileSysFatalError(err)break}@@ -209,14 +215,23 @@ func CheckFileSysStatus() {break}- count := 0+ checkFilenames := bytes.Buffer{}for _, entry := range entries {if !entry.IsDir() && strings.Contains(entry.Name(), "check_") {- count+++ checkFilenames.WriteString(entry.Name())+ checkFilenames.WriteString("\n")}}- if 1 < count {- reportFileSysFatalError(fmt.Errorf("dir [%s] has more than 1 file", dir))+ lines := strings.Split(strings.TrimSpace(checkFilenames.String()), "\n")+ if 1 < len(lines) {+ buf := bytes.Buffer{}+ for _, line := range lines {+ buf.WriteString(" ")+ buf.WriteString(line)+ buf.WriteString("\n")+ }+ output := buf.String()+ reportFileSysFatalError(fmt.Errorf("dir [%s] has more than 1 file:\n%s", dir, output))break}}