mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-07 16:04:19 +01:00
🎨 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:
parent
a2a3bca000
commit
6e85d12d5e
2 changed files with 19 additions and 1 deletions
|
|
@ -455,7 +455,19 @@ func GetAttributeViewContent(avID string) (content string) {
|
|||
logging.LogErrorf("parse attribute view [%s] failed: %s", avID, err)
|
||||
return
|
||||
}
|
||||
return getAttributeViewContent0(attrView)
|
||||
}
|
||||
|
||||
func GetAttributeViewContentByPath(avJSONPath string) (content string) {
|
||||
attrView, err := ParseAttributeViewByPath(avJSONPath)
|
||||
if err != nil {
|
||||
logging.LogErrorf("parse attribute view [%s] failed: %s", avJSONPath, err)
|
||||
return
|
||||
}
|
||||
return getAttributeViewContent0(attrView)
|
||||
}
|
||||
|
||||
func getAttributeViewContent0(attrView *AttributeView) (content string) {
|
||||
buf := bytes.Buffer{}
|
||||
buf.WriteString(attrView.Name)
|
||||
buf.WriteByte(' ')
|
||||
|
|
@ -486,11 +498,17 @@ func IsAttributeViewExist(avID string) bool {
|
|||
|
||||
func ParseAttributeView(avID string) (ret *AttributeView, err error) {
|
||||
avJSONPath := GetAttributeViewDataPath(avID)
|
||||
return ParseAttributeViewByPath(avJSONPath)
|
||||
}
|
||||
|
||||
func ParseAttributeViewByPath(avJSONPath string) (ret *AttributeView, err error) {
|
||||
if !filelock.IsExist(avJSONPath) {
|
||||
err = ErrViewNotFound
|
||||
return
|
||||
}
|
||||
|
||||
avID := filepath.Base(avJSONPath)
|
||||
avID = strings.TrimSuffix(avID, filepath.Ext(avID))
|
||||
data, readErr := filelock.ReadFile(avJSONPath)
|
||||
if nil != readErr {
|
||||
logging.LogErrorf("read attribute view [%s] failed: %s", avID, readErr)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue