Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

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

Nick Craig-Woode9da14ac2ed0
diff --git a/amazonclouddrive/amazonclouddrive.go b/amazonclouddrive/amazonclouddrive.go
index aadce1670..099eab877 100644
--- a/amazonclouddrive/amazonclouddrive.go
+++ b/amazonclouddrive/amazonclouddrive.go
@@ -666,6 +666,18 @@ func (f *Fs) Move(src fs.Object, remote string) (fs.Object, error) {
remote: remote,
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
}