s3: list directory key objects in versioned bucket version listings (#9842)

ListObjectVersions gated explicit directory objects on Mime ==
FolderMimeType, but an SDK PutObject of "dir/" carries a default
Content-Type (e.g. application/octet-stream), so those directory keys
were dropped from the version listing while ListObjectsV2 - which keys
off IsDirectoryKeyObject (any non-empty mime) - still showed them. Use
the same IsDirectoryKeyObject check so the two listings agree.

The directory test's storage-class assertion compared an ObjectStorageClass
constant against ObjectVersion.StorageClass (ObjectVersionStorageClass);
the values matched but the SDK enum types did not, so it only surfaced
once the directories started appearing. Use the matching constant.
This commit is contained in:
Chris Lu authored and GitHub committed 2026-06-06 18:02:33 -07:00
1 parent 6c1fd3aeab
commit 309cb32416
2 files changed
+6 -3

No files matched your search

+5 -2
View File
@@ -802,8 +802,11 @@ func (vc *versionCollector) collectVersions(currentPath, relativePath string) er
// processDirectory handles directory entries
func (vc *versionCollector) processDirectory(currentPath, entryPath string, entry *filer_pb.Entry) error {
// Handle explicit S3 directory object
if entry.Attributes.Mime == s3_constants.FolderMimeType {
// Handle explicit S3 directory object. Match ListObjectsV2's
// IsDirectoryKeyObject (any non-empty mime), not just FolderMimeType:
// an SDK PutObject of "dir/" carries a default Content-Type, so the two
// listings must agree on what counts as a directory key.
if entry.IsDirectoryKeyObject() {
vc.processExplicitDirectory(entryPath, entry)
}