index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Dan McGee <dan@archlinux.org> | 2009-10-11 12:57:57 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2009-10-11 12:57:57 -0500 |
commit | cf0d619670a4d0c67ad67e22bacbb69c203714f5 (patch) | |
tree | b4edada535df2b5beda4d9bcaf0f62e406a9c164 /src | |
parent | 8e7652f1afd7ba5198f3aa10a94c50bb67f7a407 (diff) | |
parent | 5e03941ee5fbd0cc69ac83e2dd6ad6d3e6d940cd (diff) |
-rw-r--r-- | src/pacman/callback.c | 18 |
diff --git a/src/pacman/callback.c b/src/pacman/callback.c index 1dd3ffba..858bfdf4 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -455,7 +455,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; @@ -472,9 +472,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) { @@ -485,6 +490,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) { |