From 72cb22ad2af0e8636858f72e826f80a3fb1808f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Tue, 17 Feb 2026 20:01:58 +0100 Subject: [PATCH] Refresh curl download percent only when updated --- utils/drmprocessorclientimpl.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/utils/drmprocessorclientimpl.cpp b/utils/drmprocessorclientimpl.cpp index 02ef555..2512fb8 100644 --- a/utils/drmprocessorclientimpl.cpp +++ b/utils/drmprocessorclientimpl.cpp @@ -147,6 +147,7 @@ void DRMProcessorClientImpl::randBytes(unsigned char* bytesOut, unsigned int len #define HTTP_REQ_MAX_RETRY 5 #define DISPLAY_THRESHOLD 10*1024 // Threshold to display download progression static unsigned downloadedBytes; +static int lastPercent = -1; static int downloadProgress(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) @@ -158,7 +159,11 @@ static int downloadProgress(void *clientp, curl_off_t dltotal, curl_off_t dlnow, if (dltotal) percent = (dlnow * 100) / dltotal; - std::cout << "\rDownload " << percent << "%" << std::flush; + if (lastPercent != percent) + { + std::cout << "\rDownload " << percent << "%" << std::flush; + lastPercent = percent; + } } return 0; @@ -279,6 +284,7 @@ std::string DRMProcessorClientImpl::sendHTTPRequest(const std::string& URL, cons curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, downloadProgress); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); + lastPercent = -1; for (int i=0; i