forked from TrueCloudLab/restic
forget: Add comments to snapshot policy
This commit is contained in:
parent
182b9796e4
commit
1257c2c075
1 changed files with 3 additions and 0 deletions
|
@ -183,6 +183,7 @@ type KeepReason struct {
|
||||||
// according to the policy p. list is sorted in the process. reasons contains
|
// according to the policy p. list is sorted in the process. reasons contains
|
||||||
// the reasons to keep each snapshot, it is in the same order as keep.
|
// the reasons to keep each snapshot, it is in the same order as keep.
|
||||||
func ApplyPolicy(list Snapshots, p ExpirePolicy) (keep, remove Snapshots, reasons []KeepReason) {
|
func ApplyPolicy(list Snapshots, p ExpirePolicy) (keep, remove Snapshots, reasons []KeepReason) {
|
||||||
|
// sort newest snapshots first
|
||||||
sort.Stable(list)
|
sort.Stable(list)
|
||||||
|
|
||||||
if p.Empty() {
|
if p.Empty() {
|
||||||
|
@ -256,6 +257,8 @@ func ApplyPolicy(list Snapshots, p ExpirePolicy) (keep, remove Snapshots, reason
|
||||||
// -1 means "keep all"
|
// -1 means "keep all"
|
||||||
if b.Count > 0 || b.Count == -1 {
|
if b.Count > 0 || b.Count == -1 {
|
||||||
val := b.bucker(cur.Time, nr)
|
val := b.bucker(cur.Time, nr)
|
||||||
|
// also keep the oldest snapshot if the bucket has some counts left. This maximizes the
|
||||||
|
// the history length kept while some counts are left.
|
||||||
if val != b.Last || nr == len(list)-1 {
|
if val != b.Last || nr == len(list)-1 {
|
||||||
debug.Log("keep %v %v, bucker %v, val %v\n", cur.Time, cur.id.Str(), i, val)
|
debug.Log("keep %v %v, bucker %v, val %v\n", cur.Time, cur.id.Str(), i, val)
|
||||||
keepSnap = true
|
keepSnap = true
|
||||||
|
|
Loading…
Reference in a new issue