Merge pull request #23715 from nextcloud/backport/23645/stable18

[stable18] Check if array elements exist before using them
This commit is contained in:
Roeland Jago Douma 2020-10-27 19:47:38 +01:00 committed by GitHub
commit be7c3e37bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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