From 71f7f4f543d3b75df36ab6335365b1ae90383a8f Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sat, 20 Aug 2016 17:51:48 +0200 Subject: [PATCH] Add ExpirePolicy.Empty() --- src/restic/snapshot_filter.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/restic/snapshot_filter.go b/src/restic/snapshot_filter.go index 3753e2646..595987d95 100644 --- a/src/restic/snapshot_filter.go +++ b/src/restic/snapshot_filter.go @@ -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 }