mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-08 00:04:21 +01:00
This commit is contained in:
parent
e385f9cc53
commit
51b362c18f
1 changed files with 11 additions and 4 deletions
|
|
@ -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
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue