Skip to content

serve s3: report the object's modtime as Last-Modified after a PUT - #10132

Merged
ncw merged 1 commit into
rclone:masterfrom
kevin9327:fix-serve-s3-last-modified
Oct 20, 2026
Merged

ncw merged 1 commit into
rclone:masterfrom
kevin9327:fix-serve-s3-last-modified

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

What does this change do?

Right after an object is uploaded through rclone serve s3, HeadObject and GetObject report the upload time as Last-Modified instead of the object's modification time. ListObjects reports the right time, so a client sees two different times for the same object until the metadata cache entry is evicted.

gofakes3's metadataHeaders() adds meta["Last-Modified"] = formatHeaderTime(now) to the metadata it hands to the backend. storeMeta cached that map as is, and HeadObject/GetObject build their metadata from node.ModTime() and then maps.Copy the cached map over it, so the cached upload time wins, even when X-Amz-Meta-Mtime set the modification time to something else.

storeMeta now drops Last-Modified before caching, so every path that stores metadata (PutObject, CopyObject, TouchObject and multipart uploads) is covered. This is the fix suggested in the issue.

Tests: TestPutObjectLastModified in cmd/serve/s3/put_test.go puts an object with X-Amz-Meta-Mtime set to 2021-06-06 and a Last-Modified of now, the way gofakes3 passes it, then checks HeadObject and GetObject. It fails before the change (both return the upload time) and passes after. go test ./cmd/serve/s3/ and go vet ./cmd/serve/s3/ pass.

Was the change discussed in an issue or in the forum before?

Fixes #10128

Checklist

  • I have read the contribution guidelines.
  • I have added tests for all changes in this PR if appropriate.
  • I have added documentation for the changes if appropriate.
  • All commit messages are in house style.
  • I'm done, this Pull Request is ready for review :-)

Prepared with AI assistance. I reviewed, built and tested the change myself.

…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.

@ncw ncw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you - nice fix :-)

@ncw
ncw merged commit 81e7372 into rclone:master Oct 20, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

serve s3: HeadObject/GetObject return upload time as Last-Modified after PutObject

2 participants