1
mirror of https://github.com/rclone/rclone synced 2024-12-18 07:45:55 +01:00

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
This commit is contained in:
Philip Harvey 2019-06-03 08:28:19 -06:00 committed by Nick Craig-Wood
parent ec4e7316f2
commit 1a2fb52266
2 changed files with 8 additions and 0 deletions

View File

@ -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
}

View File

@ -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