Merge pull request #1518 from restic/fix-1317-again

forget: Also run prune when only IDs are forgotten
This commit is contained in:
Alexander Neumann 2018-01-02 20:39:12 +01:00
commit 2bc4d200d4

View file

@ -162,9 +162,6 @@ func runForget(opts ForgetOptions, gopts GlobalOptions, args []string) error {
snapshotGroups[string(k)] = append(snapshotGroups[string(k)], sn) snapshotGroups[string(k)] = append(snapshotGroups[string(k)], sn)
} }
} }
if len(args) > 0 {
return nil
}
policy := restic.ExpirePolicy{ policy := restic.ExpirePolicy{
Last: opts.Last, Last: opts.Last,
@ -176,11 +173,11 @@ func runForget(opts ForgetOptions, gopts GlobalOptions, args []string) error {
Tags: opts.KeepTags, Tags: opts.KeepTags,
} }
if policy.Empty() { if policy.Empty() && len(args) == 0 {
Verbosef("no policy was specified, no snapshots will be removed\n") Verbosef("no policy was specified, no snapshots will be removed\n")
return nil
} }
if !policy.Empty() {
for k, snapshotGroup := range snapshotGroups { for k, snapshotGroup := range snapshotGroups {
var key key var key key
if json.Unmarshal([]byte(k), &key) != nil { if json.Unmarshal([]byte(k), &key) != nil {
@ -230,6 +227,7 @@ func runForget(opts ForgetOptions, gopts GlobalOptions, args []string) error {
} }
} }
} }
}
if removeSnapshots > 0 && opts.Prune { if removeSnapshots > 0 && opts.Prune {
Verbosef("%d snapshots have been removed, running prune\n", removeSnapshots) Verbosef("%d snapshots have been removed, running prune\n", removeSnapshots)