@@ -116,46 +116,46 @@ |
||
| 116 | 116 | // wait for any event |
| 117 | 117 | do { |
| 118 | 118 | switch (curl_multi_select($mh, 5)) { |
| 119 | - case -1: |
|
| 120 | - usleep(10); |
|
| 121 | - do { |
|
| 122 | - $stat = curl_multi_exec($mh, $running); |
|
| 123 | - } while ($stat === CURLM_CALL_MULTI_PERFORM); |
|
| 124 | - continue 2; |
|
| 125 | - case 0: |
|
| 126 | - continue 2; |
|
| 127 | - default: |
|
| 128 | - do { |
|
| 129 | - $stat = curl_multi_exec($mh, $running); |
|
| 130 | - } while ($stat === CURLM_CALL_MULTI_PERFORM); |
|
| 131 | - |
|
| 132 | - do { |
|
| 133 | - if ($raised = curl_multi_info_read($mh, $remains)) { |
|
| 134 | - $ch = $raised['handle']; |
|
| 135 | - $errno = curl_errno($ch); |
|
| 136 | - $info = curl_getinfo($ch); |
|
| 137 | - curl_setopt($ch, CURLOPT_FILE, STDOUT); |
|
| 138 | - $index = (int)$ch; |
|
| 139 | - $fileinfo = $chFpMap[$index]; |
|
| 140 | - unset($chFpMap[$index]); |
|
| 141 | - $fp = $fileinfo['fp']; |
|
| 142 | - $filepath = $fileinfo['filepath']; |
|
| 143 | - fclose($fp); |
|
| 144 | - if (CURLE_OK === $errno && 200 === $info['http_code']) { |
|
| 145 | - ++$this->successCnt; |
|
| 146 | - } else { |
|
| 147 | - ++$this->failureCnt; |
|
| 148 | - unlink($filepath); |
|
| 119 | + case -1: |
|
| 120 | + usleep(10); |
|
| 121 | + do { |
|
| 122 | + $stat = curl_multi_exec($mh, $running); |
|
| 123 | + } while ($stat === CURLM_CALL_MULTI_PERFORM); |
|
| 124 | + continue 2; |
|
| 125 | + case 0: |
|
| 126 | + continue 2; |
|
| 127 | + default: |
|
| 128 | + do { |
|
| 129 | + $stat = curl_multi_exec($mh, $running); |
|
| 130 | + } while ($stat === CURLM_CALL_MULTI_PERFORM); |
|
| 131 | + |
|
| 132 | + do { |
|
| 133 | + if ($raised = curl_multi_info_read($mh, $remains)) { |
|
| 134 | + $ch = $raised['handle']; |
|
| 135 | + $errno = curl_errno($ch); |
|
| 136 | + $info = curl_getinfo($ch); |
|
| 137 | + curl_setopt($ch, CURLOPT_FILE, STDOUT); |
|
| 138 | + $index = (int)$ch; |
|
| 139 | + $fileinfo = $chFpMap[$index]; |
|
| 140 | + unset($chFpMap[$index]); |
|
| 141 | + $fp = $fileinfo['fp']; |
|
| 142 | + $filepath = $fileinfo['filepath']; |
|
| 143 | + fclose($fp); |
|
| 144 | + if (CURLE_OK === $errno && 200 === $info['http_code']) { |
|
| 145 | + ++$this->successCnt; |
|
| 146 | + } else { |
|
| 147 | + ++$this->failureCnt; |
|
| 148 | + unlink($filepath); |
|
| 149 | + } |
|
| 150 | + $this->io->write($this->makeDownloadingText($info['url'])); |
|
| 151 | + curl_multi_remove_handle($mh, $ch); |
|
| 152 | + $unused[] = $ch; |
|
| 149 | 153 | } |
| 150 | - $this->io->write($this->makeDownloadingText($info['url'])); |
|
| 151 | - curl_multi_remove_handle($mh, $ch); |
|
| 152 | - $unused[] = $ch; |
|
| 153 | - } |
|
| 154 | - } while ($remains); |
|
| 154 | + } while ($remains); |
|
| 155 | 155 | |
| 156 | - if ($packages) { |
|
| 157 | - break 2; |
|
| 158 | - } |
|
| 156 | + if ($packages) { |
|
| 157 | + break 2; |
|
| 158 | + } |
|
| 159 | 159 | } |
| 160 | 160 | } while ($running); |
| 161 | 161 | } while ($packages); |
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * hirak/prestissimo |
|
| 4 | - * @author Hiraku NAKANO |
|
| 5 | - * @license MIT https://github.com/hirak/prestissimo |
|
| 6 | - */ |
|
| 3 | + * hirak/prestissimo |
|
| 4 | + * @author Hiraku NAKANO |
|
| 5 | + * @license MIT https://github.com/hirak/prestissimo |
|
| 6 | + */ |
|
| 7 | 7 | namespace Hirak\Prestissimo; |
| 8 | 8 | |
| 9 | 9 | /** |