index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Xavier Chantry <shiningxc@gmail.com> | 2009-09-26 02:42:27 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2009-10-04 09:32:02 -0500 |
commit | 44a57c890b2ecba85dbd8364594883439634f630 (patch) | |
tree | 71a9cb8f2807baa27b22789a15c9c624d1103b56 | |
parent | 20392c0a025d01128eb78c6656db7c15b3fbcd89 (diff) |
-rw-r--r-- | src/pacman/callback.c | 18 |
diff --git a/src/pacman/callback.c b/src/pacman/callback.c index e83a97d2..1cdb1153 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -439,7 +439,7 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total) int len, wclen, wcwid, padwid; wchar_t *wcfname; - int totaldownload; + int totaldownload = 0; off_t xfered, total; float rate = 0.0, timediff = 0.0, f_xfered = 0.0; unsigned int eta_h = 0, eta_m = 0, eta_s = 0; @@ -456,9 +456,14 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total) /* only use TotalDownload if enabled and we have a callback value */ if(config->totaldownload && list_total) { - totaldownload = 1; - } else { - totaldownload = 0; + /* sanity check */ + if(list_xfered + file_total <= list_total) { + totaldownload = 1; + } else { + /* bogus values : don't enable totaldownload and reset */ + list_xfered = 0; + list_total = 0; + } } if(totaldownload) { @@ -469,6 +474,11 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total) total = file_total; } + /* bogus values : stop here */ + if(xfered > total) { + return; + } + /* this is basically a switch on xfered: 0, total, and * anything else */ if(file_xfered == 0) { |