2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-22 10:58:55 +00:00

forget: Also run prune when only IDs are forgotten

This commit is contained in:
Alexander Neumann 2018-01-01 21:27:40 +01:00
parent 559946c58a
commit c912b38bf0

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)