"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
Implement --no-update-modtime flag - fixes #511
Nick Craig-Woodb9479cf7ab5b
diff --git a/docs/content/docs.md b/docs/content/docs.mdindex 66ae96819..4930b5bed 100644--- a/docs/content/docs.md+++ b/docs/content/docs.md@@ -560,6 +560,14 @@ uploaded compressed files.There is no need to set this in normal operation, and doing so willdecrease the network transfer efficiency of rclone.+### --no-update-modtime ###++When using this flag, rclone won't update modification times of remote+files if they are incorrect as it would normally.++This can be used if the remote is being synced with another tool also+(eg the Google Drive client).+### -q, --quiet ###Normally rclone outputs stats and a completion message. If you setdiff --git a/fs/config.go b/fs/config.goindex ba26a6de6..2f01046ce 100644--- a/fs/config.go+++ b/fs/config.go@@ -89,6 +89,7 @@ var (maxDepth = pflag.IntP("max-depth", "", -1, "If set limits the recursion depth to this.")ignoreSize = pflag.BoolP("ignore-size", "", false, "Ignore size when skipping use mod-time or checksum.")noTraverse = pflag.BoolP("no-traverse", "", false, "Don't traverse destination file system on copy.")+ noUpdateModTime = pflag.BoolP("no-update-modtime", "", false, "Don't update destination mod-time if files identical.")bwLimit SizeSuffix// Key to use for password en/decryption.@@ -240,6 +241,7 @@ type ConfigInfo struct {MaxDepth intIgnoreSize boolNoTraverse bool+ NoUpdateModTime bool}// Transport returns an http.RoundTripper with the correct timeouts@@ -345,6 +347,7 @@ func LoadConfig() {Config.MaxDepth = *maxDepthConfig.IgnoreSize = *ignoreSizeConfig.NoTraverse = *noTraverse+ Config.NoUpdateModTime = *noUpdateModTimeConfigPath = *configFilediff --git a/fs/operations.go b/fs/operations.goindex 5a247ed02..b759e2c35 100644--- a/fs/operations.go+++ b/fs/operations.go@@ -147,7 +147,7 @@ func Equal(src, dst Object) bool {return false}- if !Config.CheckSum {+ if !(Config.CheckSum || Config.NoUpdateModTime) {// Size and hash the same but mtime different so update the// mtime of the dst object hereerr := dst.SetModTime(srcModTime)diff --git a/fs/sync_test.go b/fs/sync_test.goindex 853b1c743..b0d7e2180 100644--- a/fs/sync_test.go+++ b/fs/sync_test.go@@ -311,6 +311,25 @@ func TestSyncAfterChangingModtimeOnly(t *testing.T) {fstest.CheckItems(t, r.fremote, file1)}+func TestSyncAfterChangingModtimeOnlyWithNoUpdateModTime(t *testing.T) {+ r := NewRun(t)+ defer r.Finalise()+ fs.Config.NoUpdateModTime = true+ defer func() {+ fs.Config.NoUpdateModTime = false+ }()++ file1 := r.WriteFile("empty space", "", t2)+ file2 := r.WriteObject("empty space", "", t1)++ 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)+}+func TestSyncAfterAddingAFile(t *testing.T) {r := NewRun(t)defer r.Finalise()