Skip to content

Commit

Permalink
Using each_limit_all
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdowling committed May 22, 2015
1 parent 7ba6867 commit 34ebaa3
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions src/S3/Transfer.php
Expand Up @@ -253,7 +253,9 @@ private function createDownloadPromise()
return (new Aws\CommandPool($this->client, $commands, [
'concurrency' => $this->concurrency,
'before' => $this->before,
'rejected' => $this->getRejectFn()
'rejected' => function ($reason, $idx, Promise\PromiseInterface $p) {
$p->reject($reason);
}
]))->promise();
});
}
Expand All @@ -276,12 +278,7 @@ private function createUploadPromise()

// Create an EachPromise, that will concurrently handle the upload
// operations' yielded promises from the iterator.
return Promise\each_limit(
$files,
$this->concurrency,
null,
$this->getRejectFn()
);
return Promise\each_limit_all($files, $this->concurrency);
}

private function upload($filename)
Expand Down Expand Up @@ -370,16 +367,4 @@ private function addDebugToBefore($debug)
fwrite($debug, "Transferring {$context}\n");
};
}

/**
* Reject an aggregate promise on the first failure.
*
* @return callable
*/
private function getRejectFn()
{
return function ($reason, $idx, Promise\PromiseInterface $p) {
$p->reject($reason);
};
}
}

0 comments on commit 34ebaa3

Please sign in to comment.