Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve update tx

Daniel7e2d2bfe3703
diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go
index 270da4e606..c5d72351d7 100644
--- a/kernel/model/transaction.go
+++ b/kernel/model/transaction.go
@@ -18,6 +18,7 @@ package model
import (
"bytes"
+ "errors"
"fmt"
"path/filepath"
"sort"
@@ -696,11 +697,12 @@ func (tx *Transaction) doDelete(operation *Operation) (ret *TxErr) {
var err error
id := operation.ID
tree, err := tx.loadTree(id)
- if ErrBlockNotFound == err {
- return nil // move 以后这里会空,算作正常情况
- }
-
if nil != err {
+ if errors.Is(err, ErrBlockNotFound) {
+ // move 以后这里会空,算作正常情况
+ return
+ }
+
msg := fmt.Sprintf("load tree [%s] failed: %s", id, err)
logging.LogErrorf(msg)
return &TxErr{code: TxErrCodeBlockNotFound, id: id}
@@ -926,6 +928,10 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {
tree, err := tx.loadTree(id)
if nil != err {
+ if errors.Is(err, ErrBlockNotFound) {
+ return
+ }
+
logging.LogErrorf("load tree [%s] failed: %s", id, err)
return &TxErr{code: TxErrCodeBlockNotFound, id: id}
}