Completed
Pull Request — master (#24)
by Hiraku
02:08
created
src/ParallelDownloader.php 1 patch
Switch Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -116,46 +116,46 @@
 block discarded – undo
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);
Please login to merge, or discard this patch.