An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Invalidate bookmark attribute caches after successful batch writes https://github.com/siyuan-note/siyuan/issues/21007
Daniel94f6f2d1a390
diff --git a/kernel/model/batch_mutation_fts5_test.go b/kernel/model/batch_mutation_fts5_test.goindex b71ee26a4c..06dbfb7faa 100644--- a/kernel/model/batch_mutation_fts5_test.go+++ b/kernel/model/batch_mutation_fts5_test.go@@ -10,12 +10,41 @@ import ("testing""github.com/88250/lute/ast"+ "github.com/siyuan-note/siyuan/kernel/cache""github.com/siyuan-note/siyuan/kernel/filesys""github.com/siyuan-note/siyuan/kernel/sql""github.com/siyuan-note/siyuan/kernel/treenode""github.com/siyuan-note/siyuan/kernel/util")+func TestBookmarkMutationsRefreshCachedAttributesAfterCommit(t *testing.T) {+ fixture := setupStructureTransactionTest(t)+ setupFoldTransactionDatabase(t, fixture)+ tree, err := LoadTreeByBlockID(fixture.sourceID)+ if err != nil {+ t.Fatal(err)+ }+ node := treenode.GetNodeInTree(tree, fixture.childID)+ node.SetIALAttr("bookmark", "review")+ if err = writeTreeUpsertQueue(tree); err != nil {+ t.Fatal(err)+ }+ sql.FlushQueue()+ cache.PutBlockIALInBox(node.ID, tree.Box, map[string]string{"bookmark": "review"})+ if err = RenameBookmark("review", "done"); err != nil {+ t.Fatal(err)+ }+ if got := sql.GetBlockAttrs(node.ID)["bookmark"]; got != "done" {+ t.Fatalf("cached bookmark = %q", got)+ }+ if err = RemoveBookmark("done"); err != nil {+ t.Fatal(err)+ }+ if got := sql.GetBlockAttrs(node.ID)["bookmark"]; got != "" {+ t.Fatalf("removed bookmark remains cached: %q", got)+ }+}+func TestTagAndBookmarkMutationsRejectConcurrentEdits(t *testing.T) {for _, action := range []string{"renameTag", "removeTag", "renameBookmark", "removeBookmark"} {t.Run(action, func(t *testing.T) {diff --git a/kernel/model/bookmark.go b/kernel/model/bookmark.goindex e0a483384f..3ac465665d 100644--- a/kernel/model/bookmark.go+++ b/kernel/model/bookmark.go@@ -28,6 +28,7 @@ import ("github.com/gin-gonic/gin""github.com/siyuan-note/logging""github.com/siyuan-note/siyuan/kernel/av"+ "github.com/siyuan-note/siyuan/kernel/cache""github.com/siyuan-note/siyuan/kernel/sql""github.com/siyuan-note/siyuan/kernel/treenode""github.com/siyuan-note/siyuan/kernel/util"@@ -87,6 +88,9 @@ func removeBookmark(bookmark string, beforeCommit func()) (err error) {util.ClearPushProgress(100)return}+ for _, blockID := range blocks {+ cache.RemoveBlockIAL(blockID)+ }}util.RandomSleep(50, 150)@@ -166,6 +170,9 @@ func renameBookmark(oldBookmark, newBookmark string, beforeCommit func()) (err eutil.ClearPushProgress(100)return}+ for _, blockID := range blocks {+ cache.RemoveBlockIAL(blockID)+ }}util.RandomSleep(50, 150)