Skip to content

cmd/serve/s3: return object listings in key order - #9371

Merged
ncw merged 3 commits into
rclone:masterfrom
acme:acme/s3-pager-sort-by-key
May 2, 2026
Merged

ncw merged 3 commits into
rclone:masterfrom
acme:acme/s3-pager-sort-by-key

Conversation

@acme

@acme acme commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

What is the purpose of this change?

The S3 ListObjects response from rclone serve s3 was sorting object contents by modification time instead of object key. This made the listing order incompatible with S3 clients which expect lexicographic key ordering.

In particular, aws s3 sync assumes both source and destination iterators are ordered by key. With the old modtime ordering it could misidentify files as missing or outdated and re-download objects that were already up to date.

Change the pager to sort returned objects by key and add a regression test which uses keys and modtimes arranged so the old behaviour would fail.

Fixes #9002

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

Yes, in #9002

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 :-)

acme added 3 commits April 25, 2026 13:08
The S3 ListObjects response from `rclone serve s3` was sorting object
contents by modification time instead of object key. This made the
listing order incompatible with S3 clients which expect lexicographic
key ordering.

In particular, `aws s3 sync` assumes both source and destination
iterators are ordered by key. With the old modtime ordering it could
misidentify files as missing or outdated and re-download objects that
were already up to date.

Change the pager to sort returned objects by key and add a regression
test which uses keys and modtimes arranged so the old behaviour would
fail.

Fixes rclone#9002

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

This looks great - thank you.

And also WTAF - why were we sorting by modtime! How did you notice this?

Will merge once CI goes green

@ncw

ncw commented May 2, 2026

Copy link
Copy Markdown
Member

Ah, I see it was from linked issue :-)

@ncw
ncw merged commit 0755523 into rclone:master May 2, 2026
9 checks passed
@acme
acme deleted the acme/s3-pager-sort-by-key branch May 2, 2026 18:45
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.

Rclone Serve S3 does not list files in a sorted order

2 participants