replay: improve download prints

old-commit-hash: e5e90aeae5f1c05a50eac3ccc4f2e19d56c18bdc
This commit is contained in:
Willem Melching
2021-10-19 12:48:38 +02:00
parent e7aa4f16e5
commit 03ed20610b

View File

@@ -125,7 +125,10 @@ bool httpMultiPartDownload(const std::string &url, const std::string &target_fil
if ((ts - last_print_ts) > 2 * 1000) {
if (enable_http_logging && last_print_ts > 0) {
size_t average = (total_written - prev_total_written) / ((ts - last_print_ts) / 1000.);
std::cout << "downloading segments at " << formattedDataSize(average) << "/S" << std::endl;
int progress = std::min<int>(100, 100.0 * (double)written / (double)content_length);
size_t idx = url.find("?");
std::cout << "downloading " << (idx == std::string::npos ? url : url.substr(0, idx)) << " - " << progress << "% (" << formattedDataSize(average) << "/s)" << std::endl;
}
prev_total_written = total_written;
last_print_ts = ts;