1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-21 23:33:03 +00:00

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
This commit is contained in:
Srigovind Nayak 2024-12-15 13:26:09 +05:30
parent 6808004ad1
commit 45985e14f1
No known key found for this signature in database
GPG key ID: 09006810B7263D69

View file

@ -77,13 +77,16 @@ func ParallelRemove(ctx context.Context, repo RemoverUnpacked, fileList IDSet, f
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
})