repository: deduplicate index progress bar initializaton

This commit is contained in:
Michael Eischer
2025-09-21 17:43:44 +02:00
parent b459d66288
commit 52eb66929f
21 changed files with 41 additions and 48 deletions

View File

@@ -639,13 +639,18 @@ func (r *Repository) clearIndex() {
}
// LoadIndex loads all index files from the backend in parallel and stores them
func (r *Repository) LoadIndex(ctx context.Context, p *progress.Counter) error {
func (r *Repository) LoadIndex(ctx context.Context, p restic.TerminalCounterFactory) error {
debug.Log("Loading index")
// reset in-memory index before loading it from the repository
r.clearIndex()
err := r.idx.Load(ctx, r, p, nil)
var bar *progress.Counter
if p != nil {
bar = p.NewCounterTerminalOnly("index files loaded")
}
err := r.idx.Load(ctx, r, bar, nil)
if err != nil {
return err
}