From 87f30bc7878a8bd8cd6a7cf5591f7744b8dc923a Mon Sep 17 00:00:00 2001 From: Srigovind Nayak Date: Sun, 1 Sep 2024 17:10:32 +0530 Subject: [PATCH] forget: indicate why the oldest snapshot in a group is kept When the oldest snapshot in the list is retained, the reason is now prefixed with "oldest" to clearly indicate why it's being kept. --- internal/restic/snapshot_policy.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/restic/snapshot_policy.go b/internal/restic/snapshot_policy.go index 950c26c91..f5c90d6e4 100644 --- a/internal/restic/snapshot_policy.go +++ b/internal/restic/snapshot_policy.go @@ -260,6 +260,9 @@ func ApplyPolicy(list Snapshots, p ExpirePolicy) (keep, remove Snapshots, reason if buckets[i].Count > 0 { buckets[i].Count-- } + if nr == len(list)-1 { + b.reason = fmt.Sprintf("oldest %v", b.reason) + } keepSnapReasons = append(keepSnapReasons, b.reason) } } @@ -276,6 +279,9 @@ func ApplyPolicy(list Snapshots, p ExpirePolicy) (keep, remove Snapshots, reason debug.Log("keep %v, time %v, ID %v, bucker %v, val %v %v\n", b.reason, cur.Time, cur.id.Str(), i, val, b.Last) keepSnap = true bucketsWithin[i].Last = val + if nr == len(list)-1 { + b.reason = fmt.Sprintf("oldest %v", b.reason) + } keepSnapReasons = append(keepSnapReasons, fmt.Sprintf("%v %v", b.reason, b.Within)) } }