mirror of
https://github.com/restic/restic.git
synced 2025-10-11 03:12:38 +00:00
repository: Remove RunWorkers, report ctx.Err()
This removes RunWorkers, which had become mere overhead by successive refactors. It also ensures that each former user of that function returns any context error that occurs, so failure to complete an operation is always reported as an error.
This commit is contained in:
@@ -679,7 +679,7 @@ func (r *Repository) CreateIndexFromPacks(ctx context.Context, packsize map[rest
|
||||
for id, size := range packsize {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil
|
||||
return ctx.Err()
|
||||
case ch <- FileInfo{id, size}:
|
||||
}
|
||||
}
|
||||
@@ -705,9 +705,9 @@ func (r *Repository) CreateIndexFromPacks(ctx context.Context, packsize map[rest
|
||||
}
|
||||
|
||||
// run workers on ch
|
||||
wg.Go(func() error {
|
||||
return RunWorkers(listPackParallelism, worker)
|
||||
})
|
||||
for i := 0; i < listPackParallelism; i++ {
|
||||
wg.Go(worker)
|
||||
}
|
||||
|
||||
err = wg.Wait()
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user