Merge pull request #22776 from nextcloud/backport/22747/stable19

[stable19] fix s3 doesDirectoryExist check for empty directories
This commit is contained in:
Roeland Jago Douma 2020-09-11 08:45:06 +02:00 committed by GitHub
commit b9ef2a543f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -160,10 +160,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;