Skip to content

Commit

Permalink
🐛 Automatic cleanup of the local data repo may accidentally delete sn…
Browse files Browse the repository at this point in the history
…apshots #13203
  • Loading branch information
88250 committed Nov 19, 2024
1 parent c3b3e25 commit 7150359
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions kernel/model/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}
Expand Down

0 comments on commit 7150359

Please sign in to comment.