Skip to content

Commit e53370c

Browse files
authored
drupal-composer#102 Update CurlMulti code with Prefetcher.php from prestissimo
1 parent 756910b commit e53370c

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

src/PrestissimoFileFetcher.php

+18-20
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,24 @@ protected function fetchWithPrestissimo($version, $destination, $override) {
6262

6363
$multi = new CurlMulti();
6464
$multi->setRequests($requests);
65-
do {
66-
$multi->setupEventLoop();
67-
$multi->wait();
68-
$result = $multi->getFinishedResults();
69-
$successCnt += $result['successCnt'];
70-
$failureCnt += $result['failureCnt'];
71-
if (isset($result['errors'])) {
72-
$errors += $result['errors'];
73-
}
74-
if ($this->progress) {
75-
foreach ($result['urls'] as $url) {
76-
$this->io->writeError(" - Downloading <comment>$successCnt</comment>/<comment>$totalCnt</comment>: <info>$url</info>", TRUE);
77-
}
78-
}
79-
} while ($multi->remain());
80-
81-
$urls = array_keys($errors);
82-
if ($urls) {
83-
throw new \Exception('Failed to download ' . implode(", ", $urls));
84-
}
65+
try {
66+
do {
67+
$multi->setupEventLoop();
68+
$multi->wait();
69+
$result = $multi->getFinishedResults();
70+
$successCnt += $result['successCnt'];
71+
$failureCnt += $result['failureCnt'];
72+
foreach ($result['urls'] as $url) {
73+
if (isset($result['errors'][$url])) {
74+
$this->io->writeError(" - Downloading <warning>$successCnt</warning>/<warning>$totalCnt</warning>: <warning>$url</warning>", TRUE);
75+
} else {
76+
$this->io->writeError(" - Downloading <comment>$successCnt</comment>/<comment>$totalCnt</comment>: <info>$url</info>", TRUE);
77+
}
78+
}
79+
} while ($multi->remain());
80+
} catch (FetchException $e) {
81+
// do nothing
82+
}
8583
}
8684

8785
}

0 commit comments

Comments
 (0)