"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
operations: implement --refresh-times flag to set modtimes on hashless backends
Nick Craig-Wood3efdf5e09529
diff --git a/docs/content/docs.md b/docs/content/docs.mdindex aa6d154d4..0351dfd62 100644--- a/docs/content/docs.md+++ b/docs/content/docs.md@@ -1096,6 +1096,41 @@ is fixed all non-ASCII characters will be replaced with `.` whenThis flag will limit rclone's output to error messages only.+### --refresh-times ###++The `--refresh-times` flag can be used to update modification times of+existing files when they are out of sync on backends which don't+support hashes.++This is useful if you uploaded files with the incorrect timestamps and+you now wish to correct them.++This flag is **only** useful for destinations which don't support+hashes (eg `crypt`).++This can be used any of the sync commands `sync`, `copy` or `move`.++To use this flag you will need to be doing a modification time sync+(so not using `--size-only` or `--checksum`). The flag will have no+effect when using `--size-only` or `--checksum`.++If this flag is used when rclone comes to upload a file it will check+to see if there is an existing file on the destination. If this file+matches the source with size (and checksum if available) but has a+differing timestamp then instead of re-uploading it, rclone will+update the timestamp on the destination file. If the checksum does not+match rclone will upload the new file. If the checksum is absent (eg+on a `crypt` backend) then rclone will update the timestamp.++Note that some remotes can't set the modification time without+re-uploading the file so this flag is less useful on them.++Normally if you are doing a modification time sync rclone will update+modification times without `--refresh-times` provided that the remote+supports checksums **and** the checksums match on the file. However if the+checksums are absent then rclone will upload the file rather than+setting the timestamp as this is the safe behaviour.+### --retries int ###Retry the entire sync if it fails this many times it fails (default 3).diff --git a/fs/config.go b/fs/config.goindex df22bced4..0ba74fc75 100644--- a/fs/config.go+++ b/fs/config.go@@ -117,6 +117,7 @@ type ConfigInfo struct {UploadHeaders []*HTTPOptionDownloadHeaders []*HTTPOptionHeaders []*HTTPOption+ RefreshTimes bool}// NewConfig creates a new config with everything set to the defaultdiff --git a/fs/config/configflags/configflags.go b/fs/config/configflags/configflags.goindex 9d2120919..084b98fb7 100644--- a/fs/config/configflags/configflags.go+++ b/fs/config/configflags/configflags.go@@ -121,6 +121,7 @@ func AddFlags(flagSet *pflag.FlagSet) {flags.StringArrayVarP(flagSet, &uploadHeaders, "header-upload", "", nil, "Set HTTP header for upload transactions")flags.StringArrayVarP(flagSet, &downloadHeaders, "header-download", "", nil, "Set HTTP header for download transactions")flags.StringArrayVarP(flagSet, &headers, "header", "", nil, "Set HTTP header for all transactions")+ flags.BoolVarP(flagSet, &fs.Config.RefreshTimes, "refresh-times", "", fs.Config.RefreshTimes, "Refresh the modtime of remote files.")}// ParseHeaders converts the strings passed in via the header flags into HTTPOptionsdiff --git a/fs/operations/operations.go b/fs/operations/operations.goindex be15eff69..18f238947 100644--- a/fs/operations/operations.go+++ b/fs/operations/operations.go@@ -207,7 +207,7 @@ func equal(ctx context.Context, src fs.ObjectInfo, dst fs.Object, opt equalOpt)fs.Debugf(src, "%v differ", ht)return false}- if ht == hash.None {+ if ht == hash.None && !fs.Config.RefreshTimes {// if couldn't check hash, return that they differreturn false}