summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2012-07-17 15:38:51 +0200
committerGravatar Nikias Bassen2012-07-17 15:38:51 +0200
commitc72455263b9b0c66d8521e1017080cf3c8e40706 (patch)
tree05afc9a5143faa052bba956e23947acc4e2ed4d0 /src
parent8c7a16e033f3b57326e74267958a428fdceec37f (diff)
downloadidevicerestore-c72455263b9b0c66d8521e1017080cf3c8e40706.tar.gz
idevicerestore-c72455263b9b0c66d8521e1017080cf3c8e40706.tar.bz2
download: only redraw progress bar on percentage change
Diffstat (limited to 'src')
-rw-r--r--src/download.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/download.c b/src/download.c
index cbde282..6222502 100644
--- a/src/download.c
+++ b/src/download.c
@@ -82,12 +82,17 @@ int download_to_buffer(const char* url, char** buf, uint32_t* length)
return res;
}
+static int lastprogress = 0;
+
int download_progress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
{
double p = (dlnow / dltotal) * 100;
if (p < 100.0f) {
- print_progress_bar(p);
+ if ((int)p > lastprogress) {
+ print_progress_bar(p);
+ lastprogress = (int)p;
+ }
}
return 0;
@@ -109,6 +114,7 @@ int download_to_file(const char* url, const char* filename)
return -1;
}
+ lastprogress = 0;
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, (curl_write_callback)&fwrite);
curl_easy_setopt(handle, CURLOPT_WRITEDATA, f);
curl_easy_setopt(handle, CURLOPT_PROGRESSFUNCTION, (curl_progress_callback)&download_progress);