🎨 Supports cleaning up unreferenced databases https://github.com/siyuan-note/siyuan/issues/11569

Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel 2026-01-29 23:31:07 +08:00
parent bbfd732689
commit 2104a48b17
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -75,9 +75,6 @@ func GenerateFileHistory() {
// 生成资源文件历史
generateAssetsHistory()
// 生成数据库历史
generateAttributeViewHistory()
historyDir := util.HistoryDir
clearOutdatedHistoryDir(historyDir)
@ -640,35 +637,6 @@ func generateAssetsHistory() {
return
}
func generateAttributeViewHistory() {
attributeViews := recentModifiedAttributeViews()
if 1 > len(attributeViews) {
return
}
historyDir, err := GetHistoryDir(HistoryOpUpdate)
if err != nil {
logging.LogErrorf("get history dir failed: %s", err)
return
}
for _, file := range attributeViews {
historyPath := filepath.Join(historyDir, "storage", "av", strings.TrimPrefix(file, filepath.Join(util.DataDir, "storage", "av")))
if err = os.MkdirAll(filepath.Dir(historyPath), 0755); err != nil {
logging.LogErrorf("generate history failed: %s", err)
return
}
if err = filelock.Copy(file, historyPath); err != nil {
logging.LogErrorf("copy file [%s] to [%s] failed: %s", file, historyPath, err)
return
}
}
indexHistoryDir(filepath.Base(historyDir), util.NewLute())
return
}
func (box *Box) generateDocHistory0() {
files := box.recentModifiedDocs()
if 1 > len(files) {