From 58f58a995d8419b911b3baf31441b09c74934963 Mon Sep 17 00:00:00 2001 From: Srigovind Nayak <5201843+konidev20@users.noreply.github.com> Date: Sun, 15 Dec 2024 13:26:09 +0530 Subject: [PATCH] parallel: increment progress bar before report function which may absorb the error * sometimes, the report function may absorb the error and return nil, in those cases the bar.Add(1) method would execute even if the file deletion had failed --- internal/restic/parallel.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/restic/parallel.go b/internal/restic/parallel.go index 1c56f6848..eacb54bae 100644 --- a/internal/restic/parallel.go +++ b/internal/restic/parallel.go @@ -77,13 +77,16 @@ func ParallelRemove[FT FileTypes](ctx context.Context, repo RemoverUnpacked[FT], wg.Go(func() error { for id := range fileChan { err := repo.RemoveUnpacked(ctx, fileType, id) + if err == nil { + // increment counter only if no error + bar.Add(1) + } if report != nil { err = report(id, err) } if err != nil { return err } - bar.Add(1) } return nil })