From 1451dbdeebc564eb6feb5cded2b2f396ea0a72ec Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 15 Oct 2025 10:50:49 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/16092 Signed-off-by: Daniel <845765@qq.com> --- kernel/model/file.go | 11 +---------- kernel/model/history.go | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/kernel/model/file.go b/kernel/model/file.go index 75d455d53..42c7c87cb 100644 --- a/kernel/model/file.go +++ b/kernel/model/file.go @@ -1548,16 +1548,7 @@ func removeDoc(box *Box, p string, luteEngine *lute.Lute) { return } - // 关联的属性视图也要复制到历史中 https://github.com/siyuan-note/siyuan/issues/9567 - avNodes := tree.Root.ChildrenByType(ast.NodeAttributeView) - for _, avNode := range avNodes { - srcAvPath := filepath.Join(util.DataDir, "storage", "av", avNode.AttributeViewID+".json") - destAvPath := filepath.Join(historyDir, "storage", "av", avNode.AttributeViewID+".json") - if copyErr := filelock.Copy(srcAvPath, destAvPath); nil != copyErr { - logging.LogErrorf("copy av [%s] failed: %s", srcAvPath, copyErr) - } - } - + generateAvHistory(tree, historyDir) copyDocAssetsToDataAssets(box.ID, p) removeIDs := treenode.RootChildIDs(tree.ID) diff --git a/kernel/model/history.go b/kernel/model/history.go index 39b8c9c71..b9e64de58 100644 --- a/kernel/model/history.go +++ b/kernel/model/history.go @@ -259,7 +259,6 @@ func RollbackDocHistory(boxID, historyPath string) (err error) { } historyDir = filepath.Join(util.HistoryDir, historyDir) - // 恢复包含的的属性视图 https://github.com/siyuan-note/siyuan/issues/9567 avNodes := tree.Root.ChildrenByType(ast.NodeAttributeView) for _, avNode := range avNodes { srcAvPath := filepath.Join(historyDir, "storage", "av", avNode.AttributeViewID+".json") @@ -652,15 +651,7 @@ func (box *Box) generateDocHistory0() { if nil != loadErr { logging.LogErrorf("load tree [%s] failed: %s", file, loadErr) } else { - // 关联的属性视图也要复制到历史中 https://github.com/siyuan-note/siyuan/issues/9567 - avNodes := tree.Root.ChildrenByType(ast.NodeAttributeView) - for _, avNode := range avNodes { - srcAvPath := filepath.Join(util.DataDir, "storage", "av", avNode.AttributeViewID+".json") - destAvPath := filepath.Join(historyDir, "storage", "av", avNode.AttributeViewID+".json") - if copyErr := filelock.Copy(srcAvPath, destAvPath); nil != copyErr { - logging.LogErrorf("copy av [%s] failed: %s", srcAvPath, copyErr) - } - } + generateAvHistory(tree, historyDir) } } } @@ -789,9 +780,22 @@ func generateOpTypeHistory(tree *parse.Tree, opType string) { return } + generateAvHistory(tree, historyDir) + indexHistoryDir(filepath.Base(historyDir), util.NewLute()) } +func generateAvHistory(tree *parse.Tree, historyDir string) { + avNodes := tree.Root.ChildrenByType(ast.NodeAttributeView) + for _, avNode := range avNodes { + srcAvPath := filepath.Join(util.DataDir, "storage", "av", avNode.AttributeViewID+".json") + destAvPath := filepath.Join(historyDir, "storage", "av", avNode.AttributeViewID+".json") + if copyErr := filelock.Copy(srcAvPath, destAvPath); nil != copyErr { + logging.LogErrorf("copy av [%s] failed: %s", srcAvPath, copyErr) + } + } +} + func GetHistoryDir(suffix string) (ret string, err error) { return getHistoryDir(suffix, time.Now()) }