From 1a2fb522667e2e1a61841fa994cbb3c68a192717 Mon Sep 17 00:00:00 2001 From: Philip Harvey <32467456+pharveybattelle@users.noreply.github.com> Date: Mon, 3 Jun 2019 08:28:19 -0600 Subject: [PATCH] s3: make SetModTime work for GLACIER while syncing - Fixes #3224 Before this change rclone would fail with Failed to set modification time: InvalidObjectState: Operation is not valid for the source object's storage class when attempting to set the modification time of an object in GLACIER. After this change rclone will re-upload the object as part of a sync if it needs to change the modification time. See: https://forum.rclone.org/t/suspected-bug-in-s3-or-compatible-sync-logic-to-glacier/10187 --- backend/s3/s3.go | 3 +++ docs/content/s3.md | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/backend/s3/s3.go b/backend/s3/s3.go index 1d9c4ca32..65525ec13 100644 --- a/backend/s3/s3.go +++ b/backend/s3/s3.go @@ -1736,6 +1736,9 @@ func (o *Object) SetModTime(modTime time.Time) error { if o.fs.opt.SSEKMSKeyID != "" { req.SSEKMSKeyId = &o.fs.opt.SSEKMSKeyID } + if o.fs.opt.StorageClass == "GLACIER" || o.fs.opt.StorageClass == "DEEP_ARCHIVE" { + return fs.ErrorCantSetModTime + } if o.fs.opt.StorageClass != "" { req.StorageClass = &o.fs.opt.StorageClass } diff --git a/docs/content/s3.md b/docs/content/s3.md index 80f96e0f3..da8b8a80b 100644 --- a/docs/content/s3.md +++ b/docs/content/s3.md @@ -268,6 +268,11 @@ files whose local modtime is newer than the time it was last uploaded. The modified time is stored as metadata on the object as `X-Amz-Meta-Mtime` as floating point since the epoch accurate to 1 ns. +If the modification time needs to be updated rclone will attempt to perform a server +side copy to update the modification if the object can be copied in a single part. +In the case the object is larger than 5Gb or is in Glacier or Glacier Deep Archive +storage the object will be uploaded rather than copied. + ### Multipart uploads ### rclone supports multipart uploads with S3 which means that it can