summaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-02-08 14:11:12 +0100
committerGitHub <noreply@github.com>2018-02-08 14:11:12 +0100
commit12c9bad5b26509feee1527596b2e54b86732c788 (patch)
tree06f50a4e8d375f3071592200c1250de8771d2884 /apps/files_external/lib
parentd767d01a0c102453e224e0b43647aad54519e271 (diff)
parent84bd2b6bc910174ee87d7dcbfc767de05a5a22a5 (diff)
downloadnextcloud-server-12c9bad5b26509feee1527596b2e54b86732c788.tar.gz
nextcloud-server-12c9bad5b26509feee1527596b2e54b86732c788.zip
Merge pull request #8100 from nextcloud/s3-folder-delete
Fix deleting folders when using s3 external storage
Diffstat (limited to 'apps/files_external/lib')
-rw-r--r--apps/files_external/lib/Lib/Storage/AmazonS3.php19
1 files changed, 12 insertions, 7 deletions
diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php
index 03a24e89765..f06247c3690 100644
--- a/apps/files_external/lib/Lib/Storage/AmazonS3.php
+++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php
@@ -101,7 +101,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
$keys = array_keys($this->objectCache->getData());
$keyLength = strlen($key);
foreach ($keys as $existingKey) {
- if (substr($existingKey, 0, $keyLength) === $keys) {
+ if (substr($existingKey, 0, $keyLength) === $key) {
unset($this->objectCache[$existingKey]);
}
}
@@ -242,17 +242,22 @@ class AmazonS3 extends \OC\Files\Storage\Common {
$params['Prefix'] = $path . '/';
}
try {
+ $connection = $this->getConnection();
// Since there are no real directories on S3, we need
// to delete all objects prefixed with the path.
do {
// instead of the iterator, manually loop over the list ...
- $objects = $this->getConnection()->listObjects($params);
+ $objects = $connection->listObjects($params);
// ... so we can delete the files in batches
- $this->getConnection()->deleteObjects(array(
- 'Bucket' => $this->bucket,
- 'Objects' => $objects['Contents']
- ));
- $this->testTimeout();
+ if (isset($objects['Contents'])) {
+ $connection->deleteObjects([
+ 'Bucket' => $this->bucket,
+ 'Delete' => [
+ 'Objects' => $objects['Contents']
+ ]
+ ]);
+ $this->testTimeout();
+ }
// we reached the end when the list is no longer truncated
} while ($objects['IsTruncated']);
} catch (S3Exception $e) {