mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 15:10:12 +01:00
🎨 Generate file history when removing av entries https://github.com/siyuan-note/siyuan/issues/13717
This commit is contained in:
parent
9532edcab0
commit
dad22713df
1 changed files with 31 additions and 0 deletions
|
|
@ -2120,6 +2120,37 @@ func removeAttributeViewBlock(srcIDs []string, avID string, tx *Transaction) (er
|
||||||
}
|
}
|
||||||
|
|
||||||
err = av.SaveAttributeView(attrView)
|
err = av.SaveAttributeView(attrView)
|
||||||
|
|
||||||
|
historyDir, err := GetHistoryDir(HistoryOpUpdate)
|
||||||
|
if err != nil {
|
||||||
|
logging.LogErrorf("get history dir failed: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
blockIDs := treenode.GetMirrorAttrViewBlockIDs(avID)
|
||||||
|
for _, blockID := range blockIDs {
|
||||||
|
tree := trees[blockID]
|
||||||
|
if nil == tree {
|
||||||
|
tree, _ = LoadTreeByBlockID(blockID)
|
||||||
|
}
|
||||||
|
if nil == tree {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
historyPath := filepath.Join(historyDir, tree.Box, tree.Path)
|
||||||
|
absPath := filepath.Join(util.DataDir, tree.Box, tree.Path)
|
||||||
|
if err = filelock.Copy(absPath, historyPath); err != nil {
|
||||||
|
logging.LogErrorf("backup [path=%s] to history [%s] failed: %s", absPath, historyPath, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
srcAvPath := filepath.Join(util.DataDir, "storage", "av", avID+".json")
|
||||||
|
destAvPath := filepath.Join(historyDir, "storage", "av", avID+".json")
|
||||||
|
if copyErr := filelock.Copy(srcAvPath, destAvPath); nil != copyErr {
|
||||||
|
logging.LogErrorf("copy av [%s] failed: %s", srcAvPath, copyErr)
|
||||||
|
}
|
||||||
|
|
||||||
|
indexHistoryDir(filepath.Base(historyDir), util.NewLute())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue