diff options
author | Nikias Bassen | 2012-07-17 15:38:51 +0200 |
---|---|---|
committer | Nikias Bassen | 2012-07-17 15:38:51 +0200 |
commit | c72455263b9b0c66d8521e1017080cf3c8e40706 (patch) | |
tree | 05afc9a5143faa052bba956e23947acc4e2ed4d0 /src/download.c | |
parent | 8c7a16e033f3b57326e74267958a428fdceec37f (diff) | |
download | idevicerestore-c72455263b9b0c66d8521e1017080cf3c8e40706.tar.gz idevicerestore-c72455263b9b0c66d8521e1017080cf3c8e40706.tar.bz2 |
download: only redraw progress bar on percentage change
Diffstat (limited to 'src/download.c')
-rw-r--r-- | src/download.c | 8 |
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); |