forked from TrueCloudLab/restic
forget: make oldest snapshot marker more strict
Now, a snapshot is only marked as oldest if it's the last in the list AND its values matches the last seen value for that bucket. Also, updated the corresponding golden files for the tests.
This commit is contained in:
parent
d656a50852
commit
b69c6408a6
5 changed files with 10 additions and 10 deletions
|
@ -256,13 +256,13 @@ func ApplyPolicy(list Snapshots, p ExpirePolicy) (keep, remove Snapshots, reason
|
||||||
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
|
||||||
|
if val == b.Last && nr == len(list)-1 {
|
||||||
|
b.reason = fmt.Sprintf("oldest %v", b.reason)
|
||||||
|
}
|
||||||
buckets[i].Last = val
|
buckets[i].Last = val
|
||||||
if buckets[i].Count > 0 {
|
if buckets[i].Count > 0 {
|
||||||
buckets[i].Count--
|
buckets[i].Count--
|
||||||
}
|
}
|
||||||
if nr == len(list)-1 {
|
|
||||||
b.reason = fmt.Sprintf("oldest %v", b.reason)
|
|
||||||
}
|
|
||||||
keepSnapReasons = append(keepSnapReasons, b.reason)
|
keepSnapReasons = append(keepSnapReasons, b.reason)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -278,10 +278,10 @@ func ApplyPolicy(list Snapshots, p ExpirePolicy) (keep, remove Snapshots, reason
|
||||||
if val != b.Last || nr == len(list)-1 {
|
if val != b.Last || nr == len(list)-1 {
|
||||||
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)
|
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
|
keepSnap = true
|
||||||
bucketsWithin[i].Last = val
|
if val == b.Last && nr == len(list)-1 {
|
||||||
if nr == len(list)-1 {
|
|
||||||
b.reason = fmt.Sprintf("oldest %v", b.reason)
|
b.reason = fmt.Sprintf("oldest %v", b.reason)
|
||||||
}
|
}
|
||||||
|
bucketsWithin[i].Last = val
|
||||||
keepSnapReasons = append(keepSnapReasons, fmt.Sprintf("%v %v", b.reason, b.Within))
|
keepSnapReasons = append(keepSnapReasons, fmt.Sprintf("%v %v", b.reason, b.Within))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1978,7 +1978,7 @@
|
||||||
"paths": null
|
"paths": null
|
||||||
},
|
},
|
||||||
"matches": [
|
"matches": [
|
||||||
"oldest last snapshot"
|
"last snapshot"
|
||||||
],
|
],
|
||||||
"counters": {
|
"counters": {
|
||||||
"last": -1
|
"last": -1
|
||||||
|
|
|
@ -2169,8 +2169,8 @@
|
||||||
"paths": null
|
"paths": null
|
||||||
},
|
},
|
||||||
"matches": [
|
"matches": [
|
||||||
"oldest last snapshot",
|
"last snapshot",
|
||||||
"oldest hourly snapshot"
|
"hourly snapshot"
|
||||||
],
|
],
|
||||||
"counters": {
|
"counters": {
|
||||||
"last": -1,
|
"last": -1,
|
||||||
|
|
|
@ -1708,7 +1708,7 @@
|
||||||
"paths": null
|
"paths": null
|
||||||
},
|
},
|
||||||
"matches": [
|
"matches": [
|
||||||
"oldest hourly snapshot"
|
"hourly snapshot"
|
||||||
],
|
],
|
||||||
"counters": {
|
"counters": {
|
||||||
"hourly": -1
|
"hourly": -1
|
||||||
|
|
|
@ -1978,7 +1978,7 @@
|
||||||
"paths": null
|
"paths": null
|
||||||
},
|
},
|
||||||
"matches": [
|
"matches": [
|
||||||
"oldest last snapshot"
|
"last snapshot"
|
||||||
],
|
],
|
||||||
"counters": {
|
"counters": {
|
||||||
"last": 97
|
"last": 97
|
||||||
|
|
Loading…
Reference in a new issue