Merge pull request #23713 from nextcloud/backport/23645/stable20

[stable20] Check if array elements exist before using them
This commit is contained in:
Morris Jobke 2020-10-27 16:25:35 +01:00 committed by GitHub
commit 4ea4918b62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -165,7 +165,13 @@ class AmazonS3 extends \OC\Files\Storage\Common {
'MaxKeys' => 1,
'Delimiter' => '/',
]);
$this->directoryCache[$path] = ($result['Contents'][0]['Key'] === rtrim($path, '/') . '/') || $result['CommonPrefixes'];
if ((isset($result['Contents'][0]['Key']) && $result['Contents'][0]['Key'] === rtrim($path, '/') . '/')
|| isset($result['CommonPrefixes'])) {
$this->directoryCache[$path] = true;
} else {
$this->directoryCache[$path] = false;
}
} catch (S3Exception $e) {
if ($e->getStatusCode() === 403) {
$this->directoryCache[$path] = false;