🐛 Automatic cleanup of the local data repo may accidentally delete snapshots https://github.com/siyuan-note/siyuan/issues/13203

This commit is contained in:
Daniel 2024-11-19 23:29:27 +08:00
parent c3b3e25f4a
commit 7150359e40
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -130,10 +130,14 @@ func autoPurgeRepo(cron bool) {
}
}
todayDate := now.Format("2006-01-02")
// 筛选出每日需要保留的索引
var retentionIndexIDs []string
for _, indexes := range dateGroupedIndexes {
if len(indexes) <= Conf.Repo.RetentionIndexesDaily {
for date, indexes := range dateGroupedIndexes {
if len(indexes) <= Conf.Repo.RetentionIndexesDaily || todayDate == date {
for _, index := range indexes {
retentionIndexIDs = append(retentionIndexIDs, index.ID)
}
continue
}
@ -153,7 +157,7 @@ func autoPurgeRepo(cron bool) {
}
retentionIndexIDs = gulu.Str.RemoveDuplicatedElem(retentionIndexIDs)
if 16 > len(retentionIndexIDs) {
if 3 > len(retentionIndexIDs) {
logging.LogInfof("no index to purge [ellapsed=%.2fs]", time.Since(now).Seconds())
return
}