From 30ea77c6732486f8ea09b4ac75f67c4c64b0a121 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 9 Sep 2020 14:29:11 +0200 Subject: [PATCH] fix s3 doesDirectoryExist check for empty directories 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 --- apps/files_external/lib/Lib/Storage/AmazonS3.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php index 23f6592581..c311bc5b70 100644 --- a/apps/files_external/lib/Lib/Storage/AmazonS3.php +++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php @@ -160,7 +160,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'];