acd: After moving a file, wait for the file to no longer be in the directory

This fixes a Move followed quickly by a Copy updating the wrong file.
This commit is contained in:
Nick Craig-Wood 2017-01-19 17:21:14 +00:00
parent a4bf22e620
commit e9da14ac2e

View File

@ -666,6 +666,18 @@ func (f *Fs) Move(src fs.Object, remote string) (fs.Object, error) {
remote: remote, remote: remote,
info: dstInfo, info: dstInfo,
} }
// Wait for directory caching so we can no longer see the old object
time.Sleep(200 * time.Millisecond) // enough time 90% of the time
for i := 1; i <= fs.Config.LowLevelRetries; i++ {
_, err := srcObj.fs.NewObject(srcObj.remote) // try reading the object
if err == fs.ErrorObjectNotFound {
break
} else if err != nil {
return nil, err
}
fs.Debug(src, "Wait for directory listing to update after move %d/%d", i, fs.Config.LowLevelRetries)
time.Sleep(1 * time.Second)
}
return dstObj, nil return dstObj, nil
} }