@@ -137,16 +137,16 @@ namespace vcpkg
137137 return static_cast <WriteFilePointer*>(param)->write (contents, size, nmemb);
138138 }
139139
140- static size_t progress_callback (void * clientp, double dltotal, double dlnow, double ultotal, double ulnow)
140+ static size_t progress_callback (
141+ void * clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
141142 {
142143 (void )ultotal;
143144 (void )ulnow;
144145 auto machine_readable_progress = static_cast <MessageSink*>(clientp);
145-
146- if (dltotal > 0 )
146+ if (dltotal && machine_readable_progress)
147147 {
148- const double percent = (dlnow / dltotal) * 100.0 ;
149- machine_readable_progress->println (LocalizedString::from_raw (fmt::format (" {:.2f}%" , percent )));
148+ double percentage = (static_cast < double >( dlnow) / static_cast < double >( dltotal) ) * 100.0 ;
149+ machine_readable_progress->println (LocalizedString::from_raw (fmt::format (" {:.2f}%" , percentage )));
150150 }
151151 return 0 ;
152152 }
@@ -512,7 +512,7 @@ namespace vcpkg
512512 set_common_curl_easy_options (handle, raw_url, request_headers);
513513 curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, &write_file_callback);
514514 curl_easy_setopt (curl, CURLOPT_WRITEDATA, static_cast <void *>(&fileptr));
515- curl_easy_setopt (curl, CURLOPT_NOPROGRESS, 0L ); // enable progress
515+ curl_easy_setopt (curl, CURLOPT_NOPROGRESS, 0L ); // change from default to enable progress
516516 curl_easy_setopt (curl, CURLOPT_XFERINFOFUNCTION, &progress_callback);
517517 curl_easy_setopt (curl, CURLOPT_XFERINFODATA, static_cast <void *>(&machine_readable_progress));
518518 auto curl_code = curl_easy_perform (curl);
0 commit comments