Skip to content

Commit

Permalink
Fix error handling in PrestissimoFileFetcher (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
webflo authored Jul 21, 2018
1 parent 80c7d27 commit 90f4202
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/PrestissimoFileFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ protected function fetchWithPrestissimo($version, $destination, $override) {
}

$successCnt = $failureCnt = 0;
$errors = [];
$totalCnt = count($requests);
if ($totalCnt == 0) {
return;
}
}

$multi = new CurlMulti();
$multi->setRequests($requests);
Expand All @@ -67,12 +68,18 @@ protected function fetchWithPrestissimo($version, $destination, $override) {
$result = $multi->getFinishedResults();
$successCnt += $result['successCnt'];
$failureCnt += $result['failureCnt'];
$errors += $result['errors'];
if ($this->progress) {
foreach ($result['urls'] as $url) {
$this->io->writeError(" - Downloading <comment>$successCnt</comment>/<comment>$totalCnt</comment>: <info>$url</info>", TRUE);
}
}
} while ($multi->remain());

$urls = array_keys($errors);
if ($urls) {
throw new \Exception('Failed to download ' . implode(", ", $urls));
}
}

}

0 comments on commit 90f4202

Please sign in to comment.