Skip to content

Commit 1451dbd

Browse files
committed
🎨 #16092
Signed-off-by: Daniel <[email protected]>
1 parent 9d9c230 commit 1451dbd

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

kernel/model/file.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,16 +1548,7 @@ func removeDoc(box *Box, p string, luteEngine *lute.Lute) {
15481548
return
15491549
}
15501550

1551-
// 关联的属性视图也要复制到历史中 https://github.com/siyuan-note/siyuan/issues/9567
1552-
avNodes := tree.Root.ChildrenByType(ast.NodeAttributeView)
1553-
for _, avNode := range avNodes {
1554-
srcAvPath := filepath.Join(util.DataDir, "storage", "av", avNode.AttributeViewID+".json")
1555-
destAvPath := filepath.Join(historyDir, "storage", "av", avNode.AttributeViewID+".json")
1556-
if copyErr := filelock.Copy(srcAvPath, destAvPath); nil != copyErr {
1557-
logging.LogErrorf("copy av [%s] failed: %s", srcAvPath, copyErr)
1558-
}
1559-
}
1560-
1551+
generateAvHistory(tree, historyDir)
15611552
copyDocAssetsToDataAssets(box.ID, p)
15621553

15631554
removeIDs := treenode.RootChildIDs(tree.ID)

kernel/model/history.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
259259
}
260260
historyDir = filepath.Join(util.HistoryDir, historyDir)
261261

262-
// 恢复包含的的属性视图 https://github.com/siyuan-note/siyuan/issues/9567
263262
avNodes := tree.Root.ChildrenByType(ast.NodeAttributeView)
264263
for _, avNode := range avNodes {
265264
srcAvPath := filepath.Join(historyDir, "storage", "av", avNode.AttributeViewID+".json")
@@ -652,15 +651,7 @@ func (box *Box) generateDocHistory0() {
652651
if nil != loadErr {
653652
logging.LogErrorf("load tree [%s] failed: %s", file, loadErr)
654653
} else {
655-
// 关联的属性视图也要复制到历史中 https://github.com/siyuan-note/siyuan/issues/9567
656-
avNodes := tree.Root.ChildrenByType(ast.NodeAttributeView)
657-
for _, avNode := range avNodes {
658-
srcAvPath := filepath.Join(util.DataDir, "storage", "av", avNode.AttributeViewID+".json")
659-
destAvPath := filepath.Join(historyDir, "storage", "av", avNode.AttributeViewID+".json")
660-
if copyErr := filelock.Copy(srcAvPath, destAvPath); nil != copyErr {
661-
logging.LogErrorf("copy av [%s] failed: %s", srcAvPath, copyErr)
662-
}
663-
}
654+
generateAvHistory(tree, historyDir)
664655
}
665656
}
666657
}
@@ -789,9 +780,22 @@ func generateOpTypeHistory(tree *parse.Tree, opType string) {
789780
return
790781
}
791782

783+
generateAvHistory(tree, historyDir)
784+
792785
indexHistoryDir(filepath.Base(historyDir), util.NewLute())
793786
}
794787

788+
func generateAvHistory(tree *parse.Tree, historyDir string) {
789+
avNodes := tree.Root.ChildrenByType(ast.NodeAttributeView)
790+
for _, avNode := range avNodes {
791+
srcAvPath := filepath.Join(util.DataDir, "storage", "av", avNode.AttributeViewID+".json")
792+
destAvPath := filepath.Join(historyDir, "storage", "av", avNode.AttributeViewID+".json")
793+
if copyErr := filelock.Copy(srcAvPath, destAvPath); nil != copyErr {
794+
logging.LogErrorf("copy av [%s] failed: %s", srcAvPath, copyErr)
795+
}
796+
}
797+
}
798+
795799
func GetHistoryDir(suffix string) (ret string, err error) {
796800
return getHistoryDir(suffix, time.Now())
797801
}

0 commit comments

Comments
 (0)