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
+1 -2
View File
@@ -549,8 +549,7 @@ func runBackup(ctx context.Context, opts BackupOptions, gopts GlobalOptions, ter
printer.V("load index files")
}
bar := ui.NewIndexCounter(printer)
err = repo.LoadIndex(ctx, bar)
err = repo.LoadIndex(ctx, printer)
if err != nil {
return err
}
+2 -4
View File
@@ -168,8 +168,7 @@ func runCat(ctx context.Context, gopts GlobalOptions, args []string, term ui.Ter
return err
case "blob":
bar := ui.NewIndexCounter(printer)
err = repo.LoadIndex(ctx, bar)
err = repo.LoadIndex(ctx, printer)
if err != nil {
return err
}
@@ -196,8 +195,7 @@ func runCat(ctx context.Context, gopts GlobalOptions, args []string, term ui.Ter
return errors.Fatalf("could not find snapshot: %v", err)
}
bar := ui.NewIndexCounter(printer)
err = repo.LoadIndex(ctx, bar)
err = repo.LoadIndex(ctx, printer)
if err != nil {
return err
}
+1 -2
View File
@@ -249,8 +249,7 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args
}
printer.P("load indexes\n")
bar := ui.NewIndexCounter(printer)
hints, errs := chkr.LoadIndex(ctx, bar)
hints, errs := chkr.LoadIndex(ctx, printer)
if ctx.Err() != nil {
return summary, ctx.Err()
}
+2 -4
View File
@@ -101,13 +101,11 @@ func runCopy(ctx context.Context, opts CopyOptions, gopts GlobalOptions, args []
}
debug.Log("Loading source index")
bar := ui.NewIndexCounter(printer)
if err := srcRepo.LoadIndex(ctx, bar); err != nil {
if err := srcRepo.LoadIndex(ctx, printer); err != nil {
return err
}
bar = ui.NewIndexCounter(printer)
debug.Log("Loading destination index")
if err := dstRepo.LoadIndex(ctx, bar); err != nil {
if err := dstRepo.LoadIndex(ctx, printer); err != nil {
return err
}
+1 -2
View File
@@ -484,8 +484,7 @@ func runDebugExamine(ctx context.Context, gopts GlobalOptions, opts DebugExamine
return errors.Fatal("no pack files to examine")
}
bar := ui.NewIndexCounter(printer)
err = repo.LoadIndex(ctx, bar)
err = repo.LoadIndex(ctx, printer)
if err != nil {
return err
}
+1 -2
View File
@@ -391,8 +391,7 @@ func runDiff(ctx context.Context, opts DiffOptions, gopts GlobalOptions, args []
if !gopts.JSON {
printer.P("comparing snapshot %v to %v:\n\n", sn1.ID().Str(), sn2.ID().Str())
}
bar := ui.NewIndexCounter(printer)
if err = repo.LoadIndex(ctx, bar); err != nil {
if err = repo.LoadIndex(ctx, printer); err != nil {
return err
}
+1 -2
View File
@@ -160,8 +160,7 @@ func runDump(ctx context.Context, opts DumpOptions, gopts GlobalOptions, args []
return errors.Fatalf("failed to find snapshot: %v", err)
}
bar := ui.NewIndexCounter(printer)
err = repo.LoadIndex(ctx, bar)
err = repo.LoadIndex(ctx, printer)
if err != nil {
return err
}
+1 -2
View File
@@ -623,8 +623,7 @@ func runFind(ctx context.Context, opts FindOptions, gopts GlobalOptions, args []
if err != nil {
return err
}
bar := ui.NewIndexCounter(printer)
if err = repo.LoadIndex(ctx, bar); err != nil {
if err = repo.LoadIndex(ctx, printer); err != nil {
return err
}
+1 -2
View File
@@ -373,8 +373,7 @@ func runLs(ctx context.Context, opts LsOptions, gopts GlobalOptions, args []stri
return err
}
bar := ui.NewIndexCounter(termPrinter)
if err = repo.LoadIndex(ctx, bar); err != nil {
if err = repo.LoadIndex(ctx, termPrinter); err != nil {
return err
}
+1 -2
View File
@@ -146,8 +146,7 @@ func runMount(ctx context.Context, opts MountOptions, gopts GlobalOptions, args
}
defer unlock()
bar := ui.NewIndexCounter(printer)
err = repo.LoadIndex(ctx, bar)
err = repo.LoadIndex(ctx, printer)
if err != nil {
return err
}
+1 -2
View File
@@ -190,8 +190,7 @@ func runPruneWithRepo(ctx context.Context, opts PruneOptions, repo *repository.R
}
// loading the index before the snapshots is ok, as we use an exclusive lock here
bar := ui.NewIndexCounter(printer)
err := repo.LoadIndex(ctx, bar)
err := repo.LoadIndex(ctx, printer)
if err != nil {
return err
}
+2 -3
View File
@@ -66,8 +66,7 @@ func runRecover(ctx context.Context, gopts GlobalOptions, term ui.Terminal) erro
}
printer.P("load index files\n")
bar := ui.NewIndexCounter(printer)
if err = repo.LoadIndex(ctx, bar); err != nil {
if err = repo.LoadIndex(ctx, printer); err != nil {
return err
}
@@ -85,7 +84,7 @@ func runRecover(ctx context.Context, gopts GlobalOptions, term ui.Terminal) erro
}
printer.P("load %d trees\n", len(trees))
bar = printer.NewCounter("trees loaded")
bar := printer.NewCounter("trees loaded")
bar.SetMax(uint64(len(trees)))
for id := range trees {
tree, err := restic.LoadTree(ctx, repo, id)
+1 -2
View File
@@ -59,8 +59,7 @@ func runRepairPacks(ctx context.Context, gopts GlobalOptions, term ui.Terminal,
}
defer unlock()
bar := ui.NewIndexCounter(printer)
err = repo.LoadIndex(ctx, bar)
err = repo.LoadIndex(ctx, printer)
if err != nil {
return errors.Fatalf("%s", err)
}
+1 -2
View File
@@ -87,8 +87,7 @@ func runRepairSnapshots(ctx context.Context, gopts GlobalOptions, opts RepairOpt
return err
}
bar := ui.NewIndexCounter(printer)
if err := repo.LoadIndex(ctx, bar); err != nil {
if err := repo.LoadIndex(ctx, printer); err != nil {
return err
}
+1 -2
View File
@@ -151,8 +151,7 @@ func runRestore(ctx context.Context, opts RestoreOptions, gopts GlobalOptions,
return errors.Fatalf("failed to find snapshot: %v", err)
}
bar := ui.NewIndexCounter(printer)
err = repo.LoadIndex(ctx, bar)
err = repo.LoadIndex(ctx, printer)
if err != nil {
return err
}
+1 -2
View File
@@ -318,8 +318,7 @@ func runRewrite(ctx context.Context, opts RewriteOptions, gopts GlobalOptions, a
return err
}
bar := ui.NewIndexCounter(printer)
if err = repo.LoadIndex(ctx, bar); err != nil {
if err = repo.LoadIndex(ctx, printer); err != nil {
return err
}
+1 -2
View File
@@ -111,8 +111,7 @@ func runStats(ctx context.Context, opts StatsOptions, gopts GlobalOptions, args
if err != nil {
return err
}
bar := ui.NewIndexCounter(printer)
if err = repo.LoadIndex(ctx, bar); err != nil {
if err = repo.LoadIndex(ctx, printer); err != nil {
return err
}