From 5cf7c827b86081f9e1ba97d0b40dbbdc40b88a4d Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sat, 20 Aug 2016 17:53:03 +0200 Subject: [PATCH] forget: Do nothing if no policy is configured --- src/cmds/restic/cmd_forget.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/cmds/restic/cmd_forget.go b/src/cmds/restic/cmd_forget.go index df6d97062..da1f4d4cc 100644 --- a/src/cmds/restic/cmd_forget.go +++ b/src/cmds/restic/cmd_forget.go @@ -94,7 +94,20 @@ func (cmd CmdForget) Execute(args []string) error { } else { cmd.global.Verbosef("would removed snapshot %v\n", id.Str()) } + } + policy := restic.ExpirePolicy{ + Last: cmd.Last, + Hourly: cmd.Hourly, + Daily: cmd.Daily, + Weekly: cmd.Weekly, + Monthly: cmd.Monthly, + Yearly: cmd.Yearly, + } + + if policy.Empty() { + cmd.global.Verbosef("no expire policy configured, exiting\n") + return nil } // then, load all remaining snapshots @@ -118,15 +131,6 @@ func (cmd CmdForget) Execute(args []string) error { snapshotGroups[k] = list } - policy := restic.ExpirePolicy{ - Last: cmd.Last, - Hourly: cmd.Hourly, - Daily: cmd.Daily, - Weekly: cmd.Weekly, - Monthly: cmd.Monthly, - Yearly: cmd.Yearly, - } - for key, snapshotGroup := range snapshotGroups { cmd.global.Printf("snapshots for host %v, directories %v:\n\n", key.Hostname, key.Dirs) keep, remove := restic.ApplyPolicy(snapshotGroup, policy)