2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-25 14:17:42 +00:00

hide index loading progress for JSON output

This commit is contained in:
Michael Eischer 2023-10-01 19:33:02 +02:00
parent 3fd0ad7448
commit 75f6bd89ed
15 changed files with 17 additions and 17 deletions

View File

@ -547,7 +547,7 @@ func runBackup(ctx context.Context, opts BackupOptions, gopts GlobalOptions, ter
progressPrinter.V("load index files") progressPrinter.V("load index files")
} }
bar := newTerminalProgressMax(!gopts.Quiet, 0, "index files loaded", term) bar := newTerminalProgressMax(!gopts.Quiet && !gopts.JSON, 0, "index files loaded", term)
err = repo.LoadIndex(ctx, bar) err = repo.LoadIndex(ctx, bar)
if err != nil { if err != nil {

View File

@ -169,7 +169,7 @@ func runCat(ctx context.Context, gopts GlobalOptions, args []string) error {
return err return err
case "blob": case "blob":
bar := newProgressMax(!gopts.Quiet, 0, "index files loaded") bar := newProgressMax(!gopts.Quiet && !gopts.JSON, 0, "index files loaded")
err = repo.LoadIndex(ctx, bar) err = repo.LoadIndex(ctx, bar)
if err != nil { if err != nil {
return err return err
@ -198,7 +198,7 @@ func runCat(ctx context.Context, gopts GlobalOptions, args []string) error {
return errors.Fatalf("could not find snapshot: %v\n", err) return errors.Fatalf("could not find snapshot: %v\n", err)
} }
bar := newProgressMax(!gopts.Quiet, 0, "index files loaded") bar := newProgressMax(!gopts.Quiet && !gopts.JSON, 0, "index files loaded")
err = repo.LoadIndex(ctx, bar) err = repo.LoadIndex(ctx, bar)
if err != nil { if err != nil {
return err return err

View File

@ -99,11 +99,11 @@ func runCopy(ctx context.Context, opts CopyOptions, gopts GlobalOptions, args []
} }
debug.Log("Loading source index") debug.Log("Loading source index")
bar := newProgressMax(!gopts.Quiet, 0, "index files loaded") bar := newProgressMax(!gopts.Quiet && !gopts.JSON, 0, "index files loaded")
if err := srcRepo.LoadIndex(ctx, bar); err != nil { if err := srcRepo.LoadIndex(ctx, bar); err != nil {
return err return err
} }
bar = newProgressMax(!gopts.Quiet, 0, "index files loaded") bar = newProgressMax(!gopts.Quiet && !gopts.JSON, 0, "index files loaded")
debug.Log("Loading destination index") debug.Log("Loading destination index")
if err := dstRepo.LoadIndex(ctx, bar); err != nil { if err := dstRepo.LoadIndex(ctx, bar); err != nil {
return err return err

View File

@ -469,7 +469,7 @@ func runDebugExamine(ctx context.Context, gopts GlobalOptions, args []string) er
} }
} }
bar := newProgressMax(!gopts.Quiet, 0, "index files loaded") bar := newProgressMax(!gopts.Quiet && !gopts.JSON, 0, "index files loaded")
err = repo.LoadIndex(ctx, bar) err = repo.LoadIndex(ctx, bar)
if err != nil { if err != nil {
return err return err

View File

@ -363,7 +363,7 @@ func runDiff(ctx context.Context, opts DiffOptions, gopts GlobalOptions, args []
if !gopts.JSON { if !gopts.JSON {
Verbosef("comparing snapshot %v to %v:\n\n", sn1.ID().Str(), sn2.ID().Str()) Verbosef("comparing snapshot %v to %v:\n\n", sn1.ID().Str(), sn2.ID().Str())
} }
bar := newProgressMax(!gopts.Quiet, 0, "index files loaded") bar := newProgressMax(!gopts.Quiet && !gopts.JSON, 0, "index files loaded")
if err = repo.LoadIndex(ctx, bar); err != nil { if err = repo.LoadIndex(ctx, bar); err != nil {
return err return err
} }

View File

@ -152,7 +152,7 @@ func runDump(ctx context.Context, opts DumpOptions, gopts GlobalOptions, args []
return errors.Fatalf("failed to find snapshot: %v", err) return errors.Fatalf("failed to find snapshot: %v", err)
} }
bar := newProgressMax(!gopts.Quiet, 0, "index files loaded") bar := newProgressMax(!gopts.Quiet && !gopts.JSON, 0, "index files loaded")
err = repo.LoadIndex(ctx, bar) err = repo.LoadIndex(ctx, bar)
if err != nil { if err != nil {
return err return err

View File

@ -589,7 +589,7 @@ func runFind(ctx context.Context, opts FindOptions, gopts GlobalOptions, args []
if err != nil { if err != nil {
return err return err
} }
bar := newProgressMax(!gopts.Quiet, 0, "index files loaded") bar := newProgressMax(!gopts.Quiet && !gopts.JSON, 0, "index files loaded")
if err = repo.LoadIndex(ctx, bar); err != nil { if err = repo.LoadIndex(ctx, bar); err != nil {
return err return err
} }

View File

@ -173,7 +173,7 @@ func runLs(ctx context.Context, opts LsOptions, gopts GlobalOptions, args []stri
return err return err
} }
bar := newProgressMax(!gopts.Quiet, 0, "index files loaded") bar := newProgressMax(!gopts.Quiet && !gopts.JSON, 0, "index files loaded")
if err = repo.LoadIndex(ctx, bar); err != nil { if err = repo.LoadIndex(ctx, bar); err != nil {
return err return err
} }

View File

@ -130,7 +130,7 @@ func runMount(ctx context.Context, opts MountOptions, gopts GlobalOptions, args
} }
} }
bar := newProgressMax(!gopts.Quiet, 0, "index files loaded") bar := newProgressMax(!gopts.Quiet && !gopts.JSON, 0, "index files loaded")
err = repo.LoadIndex(ctx, bar) err = repo.LoadIndex(ctx, bar)
if err != nil { if err != nil {
return err return err

View File

@ -187,7 +187,7 @@ func runPruneWithRepo(ctx context.Context, opts PruneOptions, gopts GlobalOption
Verbosef("loading indexes...\n") Verbosef("loading indexes...\n")
// loading the index before the snapshots is ok, as we use an exclusive lock here // loading the index before the snapshots is ok, as we use an exclusive lock here
bar := newProgressMax(!gopts.Quiet, 0, "index files loaded") bar := newProgressMax(!gopts.Quiet && !gopts.JSON, 0, "index files loaded")
err := repo.LoadIndex(ctx, bar) err := repo.LoadIndex(ctx, bar)
if err != nil { if err != nil {
return err return err

View File

@ -58,7 +58,7 @@ func runRecover(ctx context.Context, gopts GlobalOptions) error {
} }
Verbosef("load index files\n") Verbosef("load index files\n")
bar := newProgressMax(!gopts.Quiet, 0, "index files loaded") bar := newProgressMax(!gopts.Quiet && !gopts.JSON, 0, "index files loaded")
if err = repo.LoadIndex(ctx, bar); err != nil { if err = repo.LoadIndex(ctx, bar); err != nil {
return err return err
} }

View File

@ -89,7 +89,7 @@ func runRepairSnapshots(ctx context.Context, gopts GlobalOptions, opts RepairOpt
return err return err
} }
bar := newProgressMax(!gopts.Quiet, 0, "index files loaded") bar := newProgressMax(!gopts.Quiet && !gopts.JSON, 0, "index files loaded")
if err := repo.LoadIndex(ctx, bar); err != nil { if err := repo.LoadIndex(ctx, bar); err != nil {
return err return err
} }

View File

@ -173,7 +173,7 @@ func runRestore(ctx context.Context, opts RestoreOptions, gopts GlobalOptions,
return errors.Fatalf("failed to find snapshot: %v", err) return errors.Fatalf("failed to find snapshot: %v", err)
} }
bar := newTerminalProgressMax(!gopts.Quiet, 0, "index files loaded", term) bar := newTerminalProgressMax(!gopts.Quiet && !gopts.JSON, 0, "index files loaded", term)
err = repo.LoadIndex(ctx, bar) err = repo.LoadIndex(ctx, bar)
if err != nil { if err != nil {
return err return err

View File

@ -212,7 +212,7 @@ func runRewrite(ctx context.Context, opts RewriteOptions, gopts GlobalOptions, a
return err return err
} }
bar := newProgressMax(!gopts.Quiet, 0, "index files loaded") bar := newProgressMax(!gopts.Quiet && !gopts.JSON, 0, "index files loaded")
if err = repo.LoadIndex(ctx, bar); err != nil { if err = repo.LoadIndex(ctx, bar); err != nil {
return err return err
} }

View File

@ -98,7 +98,7 @@ func runStats(ctx context.Context, opts StatsOptions, gopts GlobalOptions, args
if err != nil { if err != nil {
return err return err
} }
bar := newProgressMax(!gopts.Quiet, 0, "index files loaded") bar := newProgressMax(!gopts.Quiet && !gopts.JSON, 0, "index files loaded")
if err = repo.LoadIndex(ctx, bar); err != nil { if err = repo.LoadIndex(ctx, bar); err != nil {
return err return err
} }