Skip to content

Rclone Serve S3 does not list files in a sorted order #9002

Closed

Description

@vqng

The associated forum post URL from https://forum.rclone.org

https://forum.rclone.org/t/rclone-serve-s3-does-not-list-files-in-a-sorted-order/53065

What is the problem you are having with rclone?

The rclone serve s3 feature serves an S3 server and it’s not compatible with the official aws s3 sync cli utility. The root cause is because ListObjects operation does not return a sorted list of objects (it’s sorted by mod time, not object names). The official aws s3 sync command assumes a sorted list by name returned by the API when it processes src and dest iterators (src). When used with a custom S3 backend served by rclone, the aws s3 sync command mistakenly identifies missing files at the destination and redownload already up-to-date files.

What is your rclone version (output from rclone version)

rclone v1.72.0
- os/version: alpine 3.22.2 (64 bit)
- os/kernel: 5.15.0-69-generic (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.25.4
- go/linking: static
- go/tags: none

Which OS you are using and how many bits (e.g. Windows 7, 64 bit)

Linux 64 bit

Which cloud storage system are you using? (e.g. Google Drive)

AWS S3

The command you were trying to run (e.g. rclone copy /tmp remote:tmp)

rclone serve s3 mirror-server:

A log from the command with the -vv flag (e.g. output from rclone -vv copy /tmp remote:tmp)

2025/11/28 19:07:56 NOTICE: S3 root: Starting s3 server on [https://[::]:8080/]
2025/11/28 19:08:01 DEBUG : serve s3: LIST BUCKET
2025/11/28 19:08:01 DEBUG : serve s3: bucketname: [redacted] prefix: prefix:"[redacted]" page: {Marker: HasMarker:false MaxKeys:1000}

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Activity

  1. vqng commented on Nov 29, 2025

    @vqng
    Author

    The sort order comes from s3 pager.go (src)

    	// sort by modtime
    	sort.Slice(list.Contents, func(i, j int) bool {
    		return list.Contents[i].LastModified.Before(list.Contents[j].LastModified.Time)
    	})
    

    @ncw do you know why we need to sort the results by modtime?

  2. vqng commented on Nov 29, 2025

    @vqng
    Author

    I can confirm removing mod-time sort fixed the issue

  3. ncw commented on Nov 29, 2025

    @ncw
    Member

    No idea what this is doing!

    // sort by modtime
    sort.Slice(list.Contents, func(i, j int) bool {
    return list.Contents[i].LastModified.Before(list.Contents[j].LastModified.Time)
    })

    I suspect it needs sorting still but I haven't traced the code through

  4. added a commit that references this issue on May 2, 2026
    0755523
  5. added a commit that references this issue on May 8, 2026
    87d0b59
  6. added a commit that references this issue on Oct 6, 2026
    b3c15bc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions