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:
greatroar
2022-05-10 22:17:50 +02:00
parent ab49c14621
commit 2e0f1f5113
4 changed files with 12 additions and 31 deletions

View File

@@ -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 {