retry for certain time during s3.Move

Signed-off-by: Qi Zhicheng <leo.quote@hotmail.com>
This commit is contained in:
qizhicheng 2020-10-21 17:59:50 +08:00
parent 2800ab0224
commit 4518d50bb5

View file

@ -695,7 +695,19 @@ func (d *driver) Move(ctx context.Context, sourcePath string, destPath string) e
if err := d.copy(ctx, sourcePath, destPath); err != nil {
return err
}
return d.Delete(ctx, sourcePath)
attempt := 30
attemptRelay := 1000 // relay 500ms before next attempt
var err error
for i := 0; i < attempt; i++ {
err = d.Delete(ctx, sourcePath)
if err != nil {
time.Sleep(time.Duration(attemptRelay))
continue
} else {
break
}
}
return err
}
// copy copies an object stored at sourcePath to destPath.