adjust s3 bulk delete to new sdk syntax

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2018-01-29 15:06:10 +01:00 committed by Roeland Jago Douma
parent 966010f87f
commit c84b290a17
No known key found for this signature in database
GPG Key ID: F941078878347C0C
1 changed files with 11 additions and 6 deletions

View File

@ -244,17 +244,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) {