@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | /** |
| 87 | 87 | * Get the content. |
| 88 | 88 | * |
| 89 | - * @param string $originUrl The origin URL |
|
| 89 | + * @param string $origin The origin URL |
|
| 90 | 90 | * @param string $fileUrl The file URL |
| 91 | 91 | * @param bool $progress Display the progression |
| 92 | 92 | * @param array $options Additional context options |
@@ -106,6 +106,11 @@ discard block |
||
| 106 | 106 | }); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | + /** |
|
| 110 | + * @param string $fileUrl |
|
| 111 | + * @param boolean $progress |
|
| 112 | + * @param \Closure $exec |
|
| 113 | + */ |
|
| 109 | 114 | protected function fetch($origin, $fileUrl, $progress, $options, $exec) |
| 110 | 115 | { |
| 111 | 116 | do { |
@@ -217,11 +222,6 @@ discard block |
||
| 217 | 222 | } |
| 218 | 223 | |
| 219 | 224 | /** |
| 220 | - * @param resource<curl> $ch |
|
| 221 | - * @param int $downBytesMax |
|
| 222 | - * @param int $downBytes |
|
| 223 | - * @param int $upBytesMax |
|
| 224 | - * @param int $upBytes |
|
| 225 | 225 | */ |
| 226 | 226 | public function progress() |
| 227 | 227 | { |
@@ -121,44 +121,44 @@ |
||
| 121 | 121 | // wait for any event |
| 122 | 122 | do { |
| 123 | 123 | switch (curl_multi_select($mh, 5)) { |
| 124 | - case -1: |
|
| 125 | - usleep(10); |
|
| 126 | - do { |
|
| 127 | - $stat = curl_multi_exec($mh, $running); |
|
| 128 | - } while ($stat === CURLM_CALL_MULTI_PERFORM); |
|
| 129 | - continue 2; |
|
| 130 | - case 0: |
|
| 131 | - continue 2; |
|
| 132 | - default: |
|
| 133 | - do { |
|
| 134 | - $stat = curl_multi_exec($mh, $running); |
|
| 135 | - } while ($stat === CURLM_CALL_MULTI_PERFORM); |
|
| 136 | - |
|
| 137 | - do { |
|
| 138 | - if ($raised = curl_multi_info_read($mh, $remains)) { |
|
| 139 | - $ch = $raised['handle']; |
|
| 140 | - $errno = curl_errno($ch); |
|
| 141 | - $info = curl_getinfo($ch); |
|
| 142 | - curl_setopt($ch, CURLOPT_FILE, STDOUT); |
|
| 143 | - $index = (int)$ch; |
|
| 144 | - $outputFile = $chFpMap[$index]; |
|
| 145 | - unset($chFpMap[$index]); |
|
| 146 | - if (CURLE_OK === $errno && 200 === $info['http_code']) { |
|
| 147 | - ++$this->successCnt; |
|
| 148 | - } else { |
|
| 149 | - ++$this->failureCnt; |
|
| 150 | - $outputFile->setFailure(); |
|
| 124 | + case -1: |
|
| 125 | + usleep(10); |
|
| 126 | + do { |
|
| 127 | + $stat = curl_multi_exec($mh, $running); |
|
| 128 | + } while ($stat === CURLM_CALL_MULTI_PERFORM); |
|
| 129 | + continue 2; |
|
| 130 | + case 0: |
|
| 131 | + continue 2; |
|
| 132 | + default: |
|
| 133 | + do { |
|
| 134 | + $stat = curl_multi_exec($mh, $running); |
|
| 135 | + } while ($stat === CURLM_CALL_MULTI_PERFORM); |
|
| 136 | + |
|
| 137 | + do { |
|
| 138 | + if ($raised = curl_multi_info_read($mh, $remains)) { |
|
| 139 | + $ch = $raised['handle']; |
|
| 140 | + $errno = curl_errno($ch); |
|
| 141 | + $info = curl_getinfo($ch); |
|
| 142 | + curl_setopt($ch, CURLOPT_FILE, STDOUT); |
|
| 143 | + $index = (int)$ch; |
|
| 144 | + $outputFile = $chFpMap[$index]; |
|
| 145 | + unset($chFpMap[$index]); |
|
| 146 | + if (CURLE_OK === $errno && 200 === $info['http_code']) { |
|
| 147 | + ++$this->successCnt; |
|
| 148 | + } else { |
|
| 149 | + ++$this->failureCnt; |
|
| 150 | + $outputFile->setFailure(); |
|
| 151 | + } |
|
| 152 | + unset($outputFile); |
|
| 153 | + $this->io->write($this->makeDownloadingText($info['url'])); |
|
| 154 | + curl_multi_remove_handle($mh, $ch); |
|
| 155 | + $unused[] = $ch; |
|
| 151 | 156 | } |
| 152 | - unset($outputFile); |
|
| 153 | - $this->io->write($this->makeDownloadingText($info['url'])); |
|
| 154 | - curl_multi_remove_handle($mh, $ch); |
|
| 155 | - $unused[] = $ch; |
|
| 156 | - } |
|
| 157 | - } while ($remains); |
|
| 157 | + } while ($remains); |
|
| 158 | 158 | |
| 159 | - if ($packages) { |
|
| 160 | - break 2; |
|
| 161 | - } |
|
| 159 | + if ($packages) { |
|
| 160 | + break 2; |
|
| 161 | + } |
|
| 162 | 162 | } |
| 163 | 163 | } while ($running); |
| 164 | 164 | } while ($packages); |