mirror of
https://github.com/restic/restic.git
synced 2025-12-04 03:38:25 +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:
@@ -365,7 +365,7 @@ func (mi *MasterIndex) Save(ctx context.Context, repo restic.Repository, packBla
|
||||
select {
|
||||
case ch <- newIndex:
|
||||
case <-ctx.Done():
|
||||
return nil
|
||||
return ctx.Err()
|
||||
}
|
||||
newIndex = NewIndex()
|
||||
}
|
||||
@@ -397,10 +397,9 @@ func (mi *MasterIndex) Save(ctx context.Context, repo restic.Repository, packBla
|
||||
}
|
||||
|
||||
// run workers on ch
|
||||
wg.Go(func() error {
|
||||
return RunWorkers(saveIndexParallelism, worker)
|
||||
})
|
||||
|
||||
for i := 0; i < saveIndexParallelism; i++ {
|
||||
wg.Go(worker)
|
||||
}
|
||||
err = wg.Wait()
|
||||
|
||||
return obsolete, err
|
||||
|
||||
Reference in New Issue
Block a user