Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/11569#issuecomment-3830601722

Daniel51b362c18f8a
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index ebf46513b1..5bcf8fe1a2 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -177,11 +177,18 @@ func UnusedAttributeViews() (ret []*UnusedItem) {
}
// 按文件更新时间排序
+ modTimes := make([]time.Time, len(ret))
+ for i := range ret {
+ p := filepath.Join(util.DataDir, "storage", "av", ret[i].Item+".json")
+ if info, statErr := os.Stat(p); nil != statErr {
+ modTimes[i] = info.ModTime()
+ } else {
+ modTimes[i] = time.Time{}
+ }
+ }
sort.Slice(ret, func(i, j int) bool {
- iInfo, iErr := os.Stat(filepath.Join(util.DataDir, "storage", "av", ret[i].Item+".json"))
- jInfo, jErr := os.Stat(filepath.Join(util.DataDir, "storage", "av", ret[j].Item+".json"))
- if iErr != nil || jErr != nil {
- return iInfo.ModTime().After(jInfo.ModTime())
+ if !modTimes[i].Equal(modTimes[j]) {
+ return modTimes[i].After(modTimes[j])
}
return ret[i].Item > ret[j].Item
})