Show download rate in MB/s when it exceeds 1MB/s

This commit is contained in:
Sude 2013-08-27 10:01:04 +03:00
parent a05f9f8d60
commit 795a131c15

View File

@ -1101,7 +1101,18 @@ int Downloader::progressCallback(void *clientp, double dltotal, double dlnow, do
// assuming that config is provided. // assuming that config is provided.
printf("\033[0K\r%3.0f%% ", fraction * 100); printf("\033[0K\r%3.0f%% ", fraction * 100);
downloader->progressbar->draw(bar_length, fraction); downloader->progressbar->draw(bar_length, fraction);
printf(" %0.2f/%0.2fMB @ %0.2fkB/s ETA: %s\r", dlnow/1024/1024, dltotal/1024/1024, rate/1024, eta_ss.str().c_str()); std::string rate_unit;
if (rate > 1048576) // 1 MB
{
rate /= 1048576;
rate_unit = "MB/s";
}
else
{
rate /= 1024;
rate_unit = "kB/s";
}
printf(" %0.2f/%0.2fMB @ %0.2f%s ETA: %s\r", dlnow/1024/1024, dltotal/1024/1024, rate, rate_unit.c_str(), eta_ss.str().c_str());
fflush(stdout); fflush(stdout);
} }