repository: set progress bar maximum in Repack

This commit is contained in:
Michael Eischer 2025-10-12 18:30:24 +02:00
parent b2afccbd96
commit a0925fa922
3 changed files with 2 additions and 4 deletions

View file

@ -243,9 +243,7 @@ func copyTree(ctx context.Context, srcRepo restic.Repository, dstRepo restic.Rep
}
bar := printer.NewCounter("packs copied")
bar.SetMax(uint64(len(packList)))
err = repository.Repack(ctx, srcRepo, dstRepo, packList, copyBlobs, bar, printer.P)
bar.Done()
if err != nil {
return errors.Fatalf("%s", err)
}

View file

@ -563,9 +563,7 @@ func (plan *PrunePlan) Execute(ctx context.Context, printer progress.Printer) er
if len(plan.repackPacks) != 0 {
printer.P("repacking packs\n")
bar := printer.NewCounter("packs repacked")
bar.SetMax(uint64(len(plan.repackPacks)))
err := Repack(ctx, repo, repo, plan.repackPacks, plan.keepBlobs, bar, printer.P)
bar.Done()
if err != nil {
return errors.Fatalf("%s", err)
}

View file

@ -42,6 +42,8 @@ func Repack(
if logf == nil {
logf = func(_ string, _ ...interface{}) {}
}
p.SetMax(uint64(len(packs)))
defer p.Done()
if repo == dstRepo && dstRepo.Connections() < 2 {
return errors.New("repack step requires a backend connection limit of at least two")