Browse Source

Update weed/s3api/s3api_object_handlers_list.go

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
pull/7481/head
Chris Lu 3 weeks ago
committed by GitHub
parent
commit
81de708df2
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 6
      weed/s3api/s3api_object_handlers_list.go

6
weed/s3api/s3api_object_handlers_list.go

@ -356,9 +356,9 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m
CommonPrefixes: commonPrefixes,
}
// Sort CommonPrefixes to match AWS S3 behavior
// AWS S3 treats the delimiter character as having lower priority than other characters
// For example with delimiter '/', 'foo/' comes before 'foo+1/' even though '+' (ASCII 43) < '/' (ASCII 47)
// Sorting happens on unencoded (raw) values for correct lexicographic order
// AWS S3 treats the delimiter character specially for sorting common prefixes.
// For example, with delimiter '/', 'foo/' should come before 'foo+1/' even though '+' (ASCII 43) < '/' (ASCII 47).
// This custom comparison ensures correct S3-compatible lexicographical ordering.
sort.Slice(response.CommonPrefixes, func(i, j int) bool {
return compareWithDelimiter(response.CommonPrefixes[i].Prefix, response.CommonPrefixes[j].Prefix, delimiter)
})

Loading…
Cancel
Save