From 2cafd81d233015982a118ad7767ec53fc9f853fb Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Fri, 23 Oct 2020 12:40:12 +0200 Subject: [PATCH] Check if array elements exist before using them It seems that in some recent upgrade here. Not always the entries we expect are returned. So we should first check if they exist. As to not spam the log. Signed-off-by: Roeland Jago Douma --- apps/files_external/lib/Lib/Storage/AmazonS3.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php index b455994359..00ca4a5b8a 100644 --- a/apps/files_external/lib/Lib/Storage/AmazonS3.php +++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php @@ -164,7 +164,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;