🎨 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-30 00:03:29 +08:00
parent ea178b40f3
commit a2a3bca000
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
4 changed files with 40 additions and 38 deletions

View file

@ -18,6 +18,7 @@
package av
import (
"bytes"
"errors"
"fmt"
"os"
@ -444,6 +445,40 @@ func GetAttributeViewNameByPath(avJSONPath string) (ret string, err error) {
return
}
func GetAttributeViewContent(avID string) (content string) {
if "" == avID {
return
}
attrView, err := ParseAttributeView(avID)
if err != nil {
logging.LogErrorf("parse attribute view [%s] failed: %s", avID, err)
return
}
buf := bytes.Buffer{}
buf.WriteString(attrView.Name)
buf.WriteByte(' ')
for _, v := range attrView.Views {
buf.WriteString(v.Name)
buf.WriteByte(' ')
}
for _, keyValues := range attrView.KeyValues {
buf.WriteString(keyValues.Key.Name)
buf.WriteByte(' ')
for _, value := range keyValues.Values {
if nil != value {
buf.WriteString(value.String(true))
buf.WriteByte(' ')
}
}
}
content = strings.TrimSpace(buf.String())
return
}
func IsAttributeViewExist(avID string) bool {
avJSONPath := GetAttributeViewDataPath(avID)
return filelock.IsExist(avJSONPath)