prune/repair index: reset in-memory index after command

The current in-memory index becomes stale after prune or repair index
have run. Thus, just drop the in-memory index altogether once these
commands have finished.
This commit is contained in:
Michael Eischer
2024-04-14 13:46:21 +02:00
parent 038586dc9d
commit defd7ae729
4 changed files with 31 additions and 4 deletions

View File

@@ -98,7 +98,14 @@ func RepairIndex(ctx context.Context, repo *Repository, opts RepairIndexOptions,
}
}
return rebuildIndexFiles(ctx, repo, removePacks, obsoleteIndexes, false, printer)
err = rebuildIndexFiles(ctx, repo, removePacks, obsoleteIndexes, false, printer)
if err != nil {
return err
}
// drop outdated in-memory index
repo.ClearIndex()
return nil
}
func rebuildIndexFiles(ctx context.Context, repo restic.Repository, removePacks restic.IDSet, extraObsolete restic.IDs, skipDeletion bool, printer progress.Printer) error {