1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-15 15:53:41 +00:00

context: fix errgroup interaction with context

Fixes #3307
This commit is contained in:
Aleksandar Jankovic
2019-07-01 10:33:21 +02:00
committed by Nick Craig-Wood
parent af2596f98b
commit 7b2b396d37
2 changed files with 9 additions and 9 deletions

View File

@@ -1818,18 +1818,18 @@ func DirMove(ctx context.Context, f fs.Fs, srcRemote, dstRemote string) (err err
newPath string
}
renames := make(chan rename, fs.Config.Transfers)
g, ctx := errgroup.WithContext(context.Background())
g, gCtx := errgroup.WithContext(context.Background())
for i := 0; i < fs.Config.Transfers; i++ {
g.Go(func() error {
for job := range renames {
dstOverwritten, _ := f.NewObject(ctx, job.newPath)
_, err := Move(ctx, f, dstOverwritten, job.newPath, job.o)
dstOverwritten, _ := f.NewObject(gCtx, job.newPath)
_, err := Move(gCtx, f, dstOverwritten, job.newPath, job.o)
if err != nil {
return err
}
select {
case <-ctx.Done():
return ctx.Err()
case <-gCtx.Done():
return gCtx.Err()
default:
}