diff options
author | Robin Appelman <robin@icewind.nl> | 2017-09-18 17:47:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-18 17:47:22 +0200 |
commit | 1995c699284a1dc522ccb5d7035fd1dca277b10e (patch) | |
tree | d355bc75303f71eea701da51492fc924a3df086a /apps/files_external/3rdparty/aws-sdk-php/Guzzle/Batch/Batch.php | |
parent | ca5c3f839affb1acefc3b3d4170e13a030da613f (diff) | |
parent | f0c7b8f264e3119dc4829c10e98f92557cc2f342 (diff) | |
download | nextcloud-server-1995c699284a1dc522ccb5d7035fd1dca277b10e.tar.gz nextcloud-server-1995c699284a1dc522ccb5d7035fd1dca277b10e.zip |
Merge pull request #4410 from nextcloud/update-aws-sdk
Update aws sdk + s3 improvements
Diffstat (limited to 'apps/files_external/3rdparty/aws-sdk-php/Guzzle/Batch/Batch.php')
-rw-r--r-- | apps/files_external/3rdparty/aws-sdk-php/Guzzle/Batch/Batch.php | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Batch/Batch.php b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Batch/Batch.php deleted file mode 100644 index 4d41c54f887..00000000000 --- a/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Batch/Batch.php +++ /dev/null @@ -1,92 +0,0 @@ -<?php - -namespace Guzzle\Batch; - -use Guzzle\Batch\Exception\BatchTransferException; - -/** - * Default batch implementation used to convert queued items into smaller chunks of batches using a - * {@see BatchDivisorIterface} and transfers each batch using a {@see BatchTransferInterface}. - * - * Any exception encountered during a flush operation will throw a {@see BatchTransferException} object containing the - * batch that failed. After an exception is encountered, you can flush the batch again to attempt to finish transferring - * any previously created batches or queued items. - */ -class Batch implements BatchInterface -{ - /** @var \SplQueue Queue of items in the queue */ - protected $queue; - - /** @var array Divided batches to be transferred */ - protected $dividedBatches; - - /** @var BatchTransferInterface */ - protected $transferStrategy; - - /** @var BatchDivisorInterface */ - protected $divisionStrategy; - - /** - * @param BatchTransferInterface $transferStrategy Strategy used to transfer items - * @param BatchDivisorInterface $divisionStrategy Divisor used to create batches - */ - public function __construct(BatchTransferInterface $transferStrategy, BatchDivisorInterface $divisionStrategy) - { - $this->transferStrategy = $transferStrategy; - $this->divisionStrategy = $divisionStrategy; - $this->queue = new \SplQueue(); - $this->queue->setIteratorMode(\SplQueue::IT_MODE_DELETE); - $this->dividedBatches = array(); - } - - public function add($item) - { - $this->queue->enqueue($item); - - return $this; - } - - public function flush() - { - $this->createBatches(); - - $items = array(); - foreach ($this->dividedBatches as $batchIndex => $dividedBatch) { - while ($dividedBatch->valid()) { - $batch = $dividedBatch->current(); - $dividedBatch->next(); - try { - $this->transferStrategy->transfer($batch); - $items = array_merge($items, $batch); - } catch (\Exception $e) { - throw new BatchTransferException($batch, $items, $e, $this->transferStrategy, $this->divisionStrategy); - } - } - // Keep the divided batch down to a minimum in case of a later exception - unset($this->dividedBatches[$batchIndex]); - } - - return $items; - } - - public function isEmpty() - { - return count($this->queue) == 0 && count($this->dividedBatches) == 0; - } - - /** - * Create batches for any queued items - */ - protected function createBatches() - { - if (count($this->queue)) { - if ($batches = $this->divisionStrategy->createBatches($this->queue)) { - // Convert arrays into iterators - if (is_array($batches)) { - $batches = new \ArrayIterator($batches); - } - $this->dividedBatches[] = $batches; - } - } - } -} |