Merge pull request #1518 from restic/fix-1317-again
forget: Also run prune when only IDs are forgotten
This commit is contained in:
commit
2bc4d200d4
1 changed files with 42 additions and 44 deletions
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue