"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
sync: don't update mod times if --dry-run set - fixes #1100
Nick Craig-Woodb52c80e85c7d
diff --git a/fs/operations.go b/fs/operations.goindex 320a351fb..60695b85f 100644--- a/fs/operations.go+++ b/fs/operations.go@@ -172,17 +172,21 @@ func equal(src, dst Object, sizeOnly, checkSum bool) bool {// mod time differs but hash is the same to reset mod time if requiredif !Config.NoUpdateModTime {- // Size and hash the same but mtime different so update the- // mtime of the dst object here- err := dst.SetModTime(srcModTime)- if err == ErrorCantSetModTime {- Debugf(src, "src and dst identical but can't set mod time without re-uploading")- return false- } else if err != nil {- Stats.Error()- Errorf(dst, "Failed to set modification time: %v", err)+ if Config.DryRun {+ Logf(src, "Not updating modification time as --dry-run")} else {- Infof(src, "Updated modification time in destination")+ // Size and hash the same but mtime different so update the+ // mtime of the dst object here+ err := dst.SetModTime(srcModTime)+ if err == ErrorCantSetModTime {+ Debugf(src, "src and dst identical but can't set mod time without re-uploading")+ return false+ } else if err != nil {+ Stats.Error()+ Errorf(dst, "Failed to set modification time: %v", err)+ } else {+ Infof(src, "Updated modification time in destination")+ }}}return truediff --git a/fs/sync_test.go b/fs/sync_test.goindex e80d8173b..1c9abb98f 100644--- a/fs/sync_test.go+++ b/fs/sync_test.go@@ -308,10 +308,22 @@ func TestSyncAfterChangingModtimeOnly(t *testing.T) {fstest.CheckItems(t, r.flocal, file1)fstest.CheckItems(t, r.fremote, file2)+ fs.Config.DryRun = true+ defer func() { fs.Config.DryRun = false }()+fs.Stats.ResetCounters()err := fs.Sync(r.fremote, r.flocal)require.NoError(t, err)+ fstest.CheckItems(t, r.flocal, file1)+ fstest.CheckItems(t, r.fremote, file2)++ fs.Config.DryRun = false++ fs.Stats.ResetCounters()+ err = fs.Sync(r.fremote, r.flocal)+ require.NoError(t, err)+fstest.CheckItems(t, r.flocal, file1)fstest.CheckItems(t, r.fremote, file1)}