]> source.dussan.org Git - nextcloud-server.git/commitdiff
Check if array elements exist before using them 23713/head
authorRoeland Jago Douma <roeland@famdouma.nl>
Fri, 23 Oct 2020 10:40:12 +0000 (12:40 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Tue, 27 Oct 2020 10:57:51 +0000 (10:57 +0000)
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 <roeland@famdouma.nl>
apps/files_external/lib/Lib/Storage/AmazonS3.php

index 4510de8b6ec2a48db4adcd9ca366dc9ebd01ba67..3cdff1d6f40e5f21c13ddeb573412ff9be3cabe0 100644 (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;