2
2
mirror of https://github.com/octoleo/restic.git synced 2024-05-28 22:50:48 +00:00

Add ExpirePolicy.Empty()

This commit is contained in:
Alexander Neumann 2016-08-20 17:51:48 +02:00
parent bf47dba1c4
commit 71f7f4f543

View File

@ -67,7 +67,13 @@ type ExpirePolicy struct {
// Sum returns the maximum number of snapshots to be kept according to this
// policy.
func (e ExpirePolicy) Sum() int {
return e.Last + e.Daily + e.Weekly + e.Monthly + e.Yearly
return e.Last + e.Hourly + e.Daily + e.Weekly + e.Monthly + e.Yearly
}
// Empty returns true iff no policy has been configured (all values zero).
func (e ExpirePolicy) Empty() bool {
empty := ExpirePolicy{}
return e == empty
}
// filter is used to split a list of snapshots into those to keep and those to
@ -175,8 +181,7 @@ func (f *filter) finish() {
func ApplyPolicy(list Snapshots, p ExpirePolicy) (keep, remove Snapshots) {
sort.Sort(list)
empty := ExpirePolicy{}
if p == empty {
if p.Empty() {
return list, remove
}