🎨 List file/asset history following the limit of editor history retention days https://github.com/siyuan-note/siyuan/issues/9723

This commit is contained in:
Daniel 2023-11-22 22:11:56 +08:00
parent e0d0c5c4d5
commit f5205d846c
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 15 additions and 14 deletions

View file

@ -500,6 +500,7 @@ func clearOutdatedHistoryDir(historyDir string) {
}
now := time.Now()
ago := now.Add(-24 * time.Hour * time.Duration(Conf.Editor.HistoryRetentionDays)).Unix()
var removes []string
for _, dir := range dirs {
dirInfo, err := dir.Info()
@ -507,7 +508,7 @@ func clearOutdatedHistoryDir(historyDir string) {
logging.LogErrorf("read history dir [%s] failed: %s", dir.Name(), err)
continue
}
if Conf.Editor.HistoryRetentionDays < int(now.Sub(dirInfo.ModTime()).Hours()/24) {
if dirInfo.ModTime().Unix() < ago {
removes = append(removes, filepath.Join(historyDir, dir.Name()))
}
}
@ -517,10 +518,10 @@ func clearOutdatedHistoryDir(historyDir string) {
continue
}
//logging.LogInfof("auto removed history dir [%s]", dir)
// 清理历史库
sql.DeleteHistoriesByPathPrefixQueue(dir)
}
// 清理历史库
sql.DeleteOutdatedHistories(fmt.Sprintf("%d", ago))
}
var boxLatestHistoryTime = map[string]time.Time{}