Skip to content

Commit 187183b

Browse files
committed
fix(AmazonS3#getDirectoryMetaData): prefer directory marker metadata on cache miss
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
1 parent f4ae389 commit 187183b

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

apps/files_external/lib/Lib/Storage/AmazonS3.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -676,15 +676,25 @@ private function getDirectoryMetaData(string $path): ?array {
676676
if ($cacheEntry instanceof CacheEntry) {
677677
return $cacheEntry->getData();
678678
} else {
679-
return [
680-
'name' => basename($path),
679+
// On a cache miss, prefer the real S3 directory marker metadata before falling back
680+
// to synthetic folder data for prefix-only directories.
681+
$directoryMarker = $path === '.' ? false : $this->headObject($path . '/');
682+
if ($directoryMarker !== false) {
683+
$data = $this->objectToMetaData($directoryMarker);
684+
} else {
685+
$data = [
686+
'name' => basename($path),
687+
'mtime' => time(),
688+
'storage_mtime' => time(),
689+
'etag' => uniqid(),
690+
];
691+
}
692+
693+
return array_replace($data, [
681694
'mimetype' => FileInfo::MIMETYPE_FOLDER,
682-
'mtime' => time(),
683-
'storage_mtime' => time(),
684-
'etag' => uniqid(),
685695
'permissions' => Constants::PERMISSION_ALL,
686696
'size' => -1,
687-
];
697+
]);
688698
}
689699
}
690700

0 commit comments

Comments
 (0)