Skip to content

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

:bug: fix encrypted-notebook transactions not finding block tree #18034

Daniel3eb0b26b96b2
diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go
index c6ae74e0d6..21531bfa41 100644
--- a/kernel/model/transaction.go
+++ b/kernel/model/transaction.go
@@ -1229,6 +1229,21 @@ func (tx *Transaction) doInsert(operation *Operation) (ret *TxErr) {
break
}
}
+ if nil == bt {
+ // 全局 blocktree 找不到时,遍历已打开的加密 box 查找
+ for _, encBoxID := range treenode.GetOpenedEncryptedBoxIDs() {
+ encBTs := treenode.GetBlockTreesInBox([]string{operation.ParentID, operation.PreviousID, operation.NextID}, encBoxID)
+ for _, b := range encBTs {
+ if "" != b.ID {
+ bt = b
+ break
+ }
+ }
+ if nil != bt {
+ break
+ }
+ }
+ }
if nil == bt {
logging.LogWarnf("not found block tree [%s, %s, %s]", operation.ParentID, operation.PreviousID, operation.NextID)
util.ReloadUI() // 比如分屏后编辑器状态不一致,这里强制重新载入界面
@@ -2029,6 +2044,15 @@ func (tx *Transaction) loadTreeByBlockTree(bt *treenode.BlockTree) (ret *parse.T
func (tx *Transaction) loadTree(id string) (ret *parse.Tree, err error) {
var rootID, box, p string
bt := treenode.GetBlockTree(id)
+ if nil == bt {
+ // 全局 blocktree 找不到时,遍历已打开的加密 box 查找
+ for _, encBoxID := range treenode.GetOpenedEncryptedBoxIDs() {
+ if encBT := treenode.GetBlockTreeInBox(id, encBoxID); nil != encBT {
+ bt = encBT
+ break
+ }
+ }
+ }
if nil == bt {
return nil, ErrBlockNotFound
}