mirror of
https://github.com/restic/restic.git
synced 2026-06-09 18:39:43 +00:00
repository: deduplicate index progress bar initializaton
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user