]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix s3 doesDirectoryExist check for empty directories
authorRobin Appelman <robin@icewind.nl>
Wed, 9 Sep 2020 12:29:11 +0000 (14:29 +0200)
committerJulius Härtl <jus@bitgrid.net>
Thu, 10 Sep 2020 06:11:55 +0000 (08:11 +0200)
if a directory is empty, only the 'marker' object `/` exists.

since not all s3 implementations return just the prefix when listing objects by prefix,
when listing objects by the folder prefix, nothing will be returned if the directory is empty.
by not including the trailing slash in the prefix, the folder marked will always be returned if it exists

Signed-off-by: Robin Appelman <robin@icewind.nl>
apps/files_external/lib/Lib/Storage/AmazonS3.php

index 0b36420430487abec59dce3ae31b4a7629b0155a..dc72518897989e1184eeb152b814120e8b27c1b4 100644 (file)
@@ -161,7 +161,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
                        try {
                                $result = $this->getConnection()->listObjects([
                                        'Bucket' => $this->bucket,
-                                       'Prefix' => rtrim($path, '/') . '/',
+                                       'Prefix' => rtrim($path, '/'),
                                        'MaxKeys' => 1,
                                ]);
                                $this->directoryCache[$path] = $result['Contents'] || $result['CommonPrefixes'];