Skip to content
This repository was archived by the owner on Nov 14, 2019. It is now read-only.

Commit 1525870

Browse files
committed
Minor tweaks
1 parent eb4ba7a commit 1525870

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/Symfony/Installer/DownloadCommand.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,12 @@ protected function download()
8989

9090
/** @var ProgressBar|null $progressBar */
9191
$progressBar = null;
92-
$downloadCallback = function ($size, $downloaded, $client, $request, Response $response) use (&$progressBar) {
93-
// Don't initialize the progress bar for redirects as the size is much smaller
94-
if ($response->getStatusCode() >= 300) {
92+
$downloadCallback = function (ProgressEvent $event) use (&$progressBar) {
93+
$downloadSize = $event->downloadSize;
94+
$downloaded = $event->downloaded;
95+
96+
// progress bar is only displayed for files larger than 1MB
97+
if ($downloadSize < 1 * 1024 * 1024) {
9598
return;
9699
}
97100

@@ -103,9 +106,9 @@ protected function download()
103106
return str_pad($this->formatSize($bar->getStep()), 11, ' ', STR_PAD_LEFT);
104107
});
105108

106-
$progressBar = new ProgressBar($this->output, $size);
109+
$progressBar = new ProgressBar($this->output, $downloadSize);
107110
$progressBar->setFormat('%current%/%max% %bar% %percent:3s%%');
108-
$progressBar->setRedrawFrequency(max(1, floor($size / 1000)));
111+
$progressBar->setRedrawFrequency(max(1, floor($downloadSize / 1000)));
109112
$progressBar->setBarWidth(60);
110113

111114
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {

0 commit comments

Comments
 (0)