Repository navigation
serve s3: report the object's modtime as Last-Modified after a PUT - #10132
Merged
Merged
Conversation
…ixes rclone#10128 gofakes3 adds the time of the request as "Last-Modified" to the metadata it passes to PutObject, CopyObject and multipart uploads. storeMeta cached it with the rest, so HeadObject and GetObject replaced the object's modification time with the upload time until the cache entry was evicted, while ListObjects reported the right time. storeMeta now drops "Last-Modified" before caching the metadata.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this change do?
Right after an object is uploaded through
rclone serve s3,HeadObjectandGetObjectreport the upload time asLast-Modifiedinstead of the object's modification time.ListObjectsreports the right time, so a client sees two different times for the same object until the metadata cache entry is evicted.gofakes3's
metadataHeaders()addsmeta["Last-Modified"] = formatHeaderTime(now)to the metadata it hands to the backend.storeMetacached that map as is, andHeadObject/GetObjectbuild their metadata fromnode.ModTime()and thenmaps.Copythe cached map over it, so the cached upload time wins, even whenX-Amz-Meta-Mtimeset the modification time to something else.storeMetanow dropsLast-Modifiedbefore caching, so every path that stores metadata (PutObject, CopyObject, TouchObject and multipart uploads) is covered. This is the fix suggested in the issue.Tests:
TestPutObjectLastModifiedincmd/serve/s3/put_test.goputs an object withX-Amz-Meta-Mtimeset to 2021-06-06 and aLast-Modifiedof now, the way gofakes3 passes it, then checksHeadObjectandGetObject. It fails before the change (both return the upload time) and passes after.go test ./cmd/serve/s3/andgo vet ./cmd/serve/s3/pass.Was the change discussed in an issue or in the forum before?
Fixes #10128
Checklist
Prepared with AI assistance. I reviewed, built and tested the change myself.