Merge pull request #22747 from nextcloud/s3-isdir-empty

fix s3 doesDirectoryExist check for empty directories
pull/22661/head
Morris Jobke 2020-09-10 12:48:37 +07:00 committed by GitHub
commit 756254c36a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

@ -161,10 +161,11 @@ class AmazonS3 extends \OC\Files\Storage\Common {
try {
$result = $this->getConnection()->listObjects([
'Bucket' => $this->bucket,
'Prefix' => rtrim($path, '/') . '/',
'Prefix' => rtrim($path, '/'),
'MaxKeys' => 1,
'Delimiter' => '/',
]);
$this->directoryCache[$path] = $result['Contents'] || $result['CommonPrefixes'];
$this->directoryCache[$path] = ($result['Contents'][0]['Key'] === rtrim($path, '/') . '/') || $result['CommonPrefixes'];
} catch (S3Exception $e) {
if ($e->getStatusCode() === 403) {
$this->directoryCache[$path] = false;