Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel 2025-10-15 10:50:49 +08:00
parent 9d9c230577
commit 1451dbdeeb
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 15 additions and 20 deletions

View file

@ -1548,16 +1548,7 @@ func removeDoc(box *Box, p string, luteEngine *lute.Lute) {
return return
} }
// 关联的属性视图也要复制到历史中 https://github.com/siyuan-note/siyuan/issues/9567 generateAvHistory(tree, historyDir)
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)
}
}
copyDocAssetsToDataAssets(box.ID, p) copyDocAssetsToDataAssets(box.ID, p)
removeIDs := treenode.RootChildIDs(tree.ID) removeIDs := treenode.RootChildIDs(tree.ID)

View file

@ -259,7 +259,6 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
} }
historyDir = filepath.Join(util.HistoryDir, historyDir) historyDir = filepath.Join(util.HistoryDir, historyDir)
// 恢复包含的的属性视图 https://github.com/siyuan-note/siyuan/issues/9567
avNodes := tree.Root.ChildrenByType(ast.NodeAttributeView) avNodes := tree.Root.ChildrenByType(ast.NodeAttributeView)
for _, avNode := range avNodes { for _, avNode := range avNodes {
srcAvPath := filepath.Join(historyDir, "storage", "av", avNode.AttributeViewID+".json") srcAvPath := filepath.Join(historyDir, "storage", "av", avNode.AttributeViewID+".json")
@ -652,15 +651,7 @@ func (box *Box) generateDocHistory0() {
if nil != loadErr { if nil != loadErr {
logging.LogErrorf("load tree [%s] failed: %s", file, loadErr) logging.LogErrorf("load tree [%s] failed: %s", file, loadErr)
} else { } else {
// 关联的属性视图也要复制到历史中 https://github.com/siyuan-note/siyuan/issues/9567 generateAvHistory(tree, historyDir)
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)
}
}
} }
} }
} }
@ -789,9 +780,22 @@ func generateOpTypeHistory(tree *parse.Tree, opType string) {
return return
} }
generateAvHistory(tree, historyDir)
indexHistoryDir(filepath.Base(historyDir), util.NewLute()) 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) { func GetHistoryDir(suffix string) (ret string, err error) {
return getHistoryDir(suffix, time.Now()) return getHistoryDir(suffix, time.Now())
} }