diff options
author | Robin Appelman <robin@icewind.nl> | 2018-01-29 15:06:10 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-02-12 20:23:10 +0100 |
commit | 3257bf24246b44a84dfdfa061304920b7ab084f3 (patch) | |
tree | 0be3fa464a20a01376b63d448dc1d9cdc6719ee5 | |
parent | e47e1f6bddb9eb78217e5faf3e08f42abf4ca848 (diff) | |
download | nextcloud-server-3257bf24246b44a84dfdfa061304920b7ab084f3.tar.gz nextcloud-server-3257bf24246b44a84dfdfa061304920b7ab084f3.zip |
adjust s3 bulk delete to new sdk syntax
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r-- | apps/files_external/lib/Lib/Storage/AmazonS3.php | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php index 7c536443a0e..7f2f59bbac3 100644 --- a/apps/files_external/lib/Lib/Storage/AmazonS3.php +++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php @@ -243,17 +243,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) { |