diff --git a/src/cmds/restic/cmd_prune.go b/src/cmds/restic/cmd_prune.go index e841c7d38..aa7b9e76c 100644 --- a/src/cmds/restic/cmd_prune.go +++ b/src/cmds/restic/cmd_prune.go @@ -235,22 +235,23 @@ func pruneRepository(gopts GlobalOptions, repo restic.Repository) error { Verbosef("will delete %d packs and rewrite %d packs, this frees %s\n", len(removePacks), len(rewritePacks), formatBytes(uint64(removeBytes))) - var repackedBlobs restic.IDSet + var obsoletePacks restic.IDSet if len(rewritePacks) != 0 { bar = newProgressMax(!gopts.Quiet, uint64(len(rewritePacks)), "packs rewritten") bar.Start() - repackedBlobs, err = repository.Repack(ctx, repo, rewritePacks, usedBlobs, bar) + obsoletePacks, err = repository.Repack(ctx, repo, rewritePacks, usedBlobs, bar) if err != nil { return err } bar.Done() } + removePacks.Merge(obsoletePacks) + if err = rebuildIndex(ctx, repo, removePacks); err != nil { return err } - removePacks.Merge(repackedBlobs) if len(removePacks) != 0 { bar = newProgressMax(!gopts.Quiet, uint64(len(removePacks)), "packs deleted") bar.Start()