From e9da14ac2ed024ff06570a8d3926fc711f11e854 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 19 Jan 2017 17:21:14 +0000 Subject: [PATCH] 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. --- amazonclouddrive/amazonclouddrive.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 }