Make realistic forget --prune --dryrun

This commit is contained in:
Alexander Weiss
2020-07-19 07:13:41 +02:00
committed by Alexander Neumann
parent 7f9a0a5907
commit b2f5381737
4 changed files with 10 additions and 7 deletions

View File

@@ -214,9 +214,8 @@ func runForget(opts ForgetOptions, gopts GlobalOptions, args []string) error {
if !gopts.JSON {
Verbosef("%d snapshots have been removed, running prune\n", len(removeSnIDs))
}
pruneOptions.DryRun = opts.DryRun
return runPruneWithRepo(pruneOptions, gopts, repo)
return runPruneWithRepo(pruneOptions, gopts, repo, removeSnIDs)
}
return nil

View File

@@ -128,15 +128,15 @@ func runPrune(opts PruneOptions, gopts GlobalOptions) error {
return err
}
return runPruneWithRepo(opts, gopts, repo)
return runPruneWithRepo(opts, gopts, repo, restic.NewIDSet())
}
func runPruneWithRepo(opts PruneOptions, gopts GlobalOptions, repo *repository.Repository) error {
func runPruneWithRepo(opts PruneOptions, gopts GlobalOptions, repo *repository.Repository, ignoreSnapshots restic.IDSet) error {
// we do not need index updates while pruning!
repo.DisableAutoIndexUpdate()
Verbosef("loading all snapshots...\n")
snapshots, err := restic.LoadAllSnapshots(gopts.ctx, repo)
snapshots, err := restic.LoadAllSnapshots(gopts.ctx, repo, ignoreSnapshots)
if err != nil {
return err
}