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

swift, s3, dropbox: fix metadata read on Update()

Nick Craig-Wood282cba20a08a
diff --git a/dropbox/dropbox.go b/dropbox/dropbox.go
index 2deaf1c79..f5ec62624 100644
--- a/dropbox/dropbox.go
+++ b/dropbox/dropbox.go
@@ -668,6 +668,7 @@ func (o *FsObjectDropbox) setModTimeAndMd5sum(modTime time.Time, md5sum string)
if err != nil {
return fmt.Errorf("Couldn't set md5sum record: %s", err)
}
+ o.md5sum = md5sum
}
if !modTime.IsZero() {
@@ -676,6 +677,7 @@ func (o *FsObjectDropbox) setModTimeAndMd5sum(modTime time.Time, md5sum string)
if err != nil {
return fmt.Errorf("Couldn't set mtime record: %s", err)
}
+ o.modTime = modTime
}
return nil
diff --git a/rclonetest/rclonetest.go b/rclonetest/rclonetest.go
index 50cb4a69a..224b43da8 100644
--- a/rclonetest/rclonetest.go
+++ b/rclonetest/rclonetest.go
@@ -260,6 +260,21 @@ func TestSync(flocal, fremote fs.Fs) {
// ------------------------------------------------------------
+ log.Printf("Sync after changing a file's contents, modtime but not length")
+ WriteFile("potato", "SMALLER BUT SAME DATE", t2)
+ err = fs.Sync(fremote, flocal, true)
+ if err != nil {
+ log.Fatalf("Sync failed: %v", err)
+ }
+ items = []Item{
+ {Path: "empty space", Size: 0, ModTime: t2, Md5sum: "d41d8cd98f00b204e9800998ecf8427e"},
+ {Path: "potato", Size: 21, ModTime: t2, Md5sum: "e4cb6955d9106df6263c45fcfc10f163"},
+ }
+ CheckListing(flocal, items)
+ CheckListing(fremote, items)
+
+ // ------------------------------------------------------------
+
log.Printf("Sync after removing a file and adding a file --dry-run")
WriteFile("potato2", "------------------------------------------------------------", t1)
err = os.Remove(localName + "/potato")
@@ -275,7 +290,7 @@ func TestSync(flocal, fremote fs.Fs) {
before := []Item{
{Path: "empty space", Size: 0, ModTime: t2, Md5sum: "d41d8cd98f00b204e9800998ecf8427e"},
- {Path: "potato", Size: 21, ModTime: t3, Md5sum: "100defcf18c42a1e0dc42a789b107cd2"},
+ {Path: "potato", Size: 21, ModTime: t2, Md5sum: "e4cb6955d9106df6263c45fcfc10f163"},
}
items = []Item{
{Path: "empty space", Size: 0, ModTime: t2, Md5sum: "d41d8cd98f00b204e9800998ecf8427e"},
diff --git a/s3/s3.go b/s3/s3.go
index dc847b609..ed2bf8cd7 100644
--- a/s3/s3.go
+++ b/s3/s3.go
@@ -518,6 +518,7 @@ func (o *FsObjectS3) Update(in io.Reader, modTime time.Time, size int64) error {
return err
}
// Read the metadata from the newly created object
+ o.meta = nil // wipe old metadata
err = o.readMetaData()
return err
}
diff --git a/swift/swift.go b/swift/swift.go
index 7dd722da5..2bba19238 100644
--- a/swift/swift.go
+++ b/swift/swift.go
@@ -413,6 +413,7 @@ func (o *FsObjectSwift) Update(in io.Reader, modTime time.Time, size int64) erro
return err
}
// Read the metadata from the newly created object
+ o.meta = nil // wipe old metadata
err = o.readMetaData()
return err
}