| @@ 98-125 (lines=28) @@ | ||
| 95 | * @param $buildUrl |
|
| 96 | * @param $zipFile |
|
| 97 | */ |
|
| 98 | protected function downloadFileWithProgressBar($buildUrl, $zipFile) |
|
| 99 | { |
|
| 100 | $this->output->writeln('<info>Begin file download...</info>'); |
|
| 101 | ||
| 102 | $progressBar = new ProgressBar($this->output, 100); |
|
| 103 | $progressBar->start(); |
|
| 104 | ||
| 105 | $client = new Client(); |
|
| 106 | $request = $client->createRequest('GET', $buildUrl); |
|
| 107 | $request->getEmitter()->on('progress', function (ProgressEvent $e) use ($progressBar) { |
|
| 108 | if ($e->downloaded > 0) { |
|
| 109 | $localProgress = floor(($e->downloaded / $e->downloadSize * 100)); |
|
| 110 | ||
| 111 | if ($localProgress != $this->progress) { |
|
| 112 | $this->progress = (integer)$localProgress; |
|
| 113 | $progressBar->advance(); |
|
| 114 | } |
|
| 115 | } |
|
| 116 | }); |
|
| 117 | ||
| 118 | $response = $client->send($request); |
|
| 119 | ||
| 120 | $progressBar->finish(); |
|
| 121 | ||
| 122 | file_put_contents($zipFile, $response->getBody()); |
|
| 123 | ||
| 124 | $this->output->writeln("\n<info>File download complete...</info>"); |
|
| 125 | } |
|
| 126 | ||
| 127 | /** |
|
| 128 | * Check if the server has a newer version of the nukacode build. |
|
| @@ 252-279 (lines=28) @@ | ||
| 249 | * |
|
| 250 | * @param $buildUrl |
|
| 251 | */ |
|
| 252 | protected function downloadFileWithProgressBar($buildUrl) |
|
| 253 | { |
|
| 254 | $this->output->writeln('<info>Begin file download...</info>'); |
|
| 255 | ||
| 256 | $progressBar = new ProgressBar($this->output, 100); |
|
| 257 | $progressBar->start(); |
|
| 258 | ||
| 259 | $client = new Client(); |
|
| 260 | $request = $client->createRequest('GET', $buildUrl); |
|
| 261 | $request->getEmitter()->on('progress', function (ProgressEvent $e) use ($progressBar) { |
|
| 262 | if ($e->downloaded > 0) { |
|
| 263 | $localProgress = floor(($e->downloaded / $e->downloadSize * 100)); |
|
| 264 | ||
| 265 | if ($localProgress != $this->progress) { |
|
| 266 | $this->progress = (integer)$localProgress; |
|
| 267 | $progressBar->advance(); |
|
| 268 | } |
|
| 269 | } |
|
| 270 | }); |
|
| 271 | ||
| 272 | $response = $client->send($request); |
|
| 273 | ||
| 274 | $progressBar->finish(); |
|
| 275 | ||
| 276 | file_put_contents($this->zipFile, $response->getBody()); |
|
| 277 | ||
| 278 | $this->output->writeln("\n<info>File download complete...</info>"); |
|
| 279 | } |
|
| 280 | ||
| 281 | /** |
|
| 282 | * Check if the server has a newer version of the nukacode build. |
|