summaryrefslogtreecommitdiffstats
path: root/src/pacman/callback.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2008-10-13 04:36:45 +0200
committerDan McGee <dan@archlinux.org>2008-10-13 04:36:45 +0200
commitfa02a71abd62fc8b45e92ce1652b5d98174a6dca (patch)
tree44880adf216b6a634e90e76428b265e02df33b58 /src/pacman/callback.c
parent91a013a8791b73daf4d17b2d52c8dfaf12887cc6 (diff)
parent30851a24ff68b00898565a1144926d83c623e6bf (diff)
downloadpacman-fa02a71abd62fc8b45e92ce1652b5d98174a6dca.tar.gz
pacman-fa02a71abd62fc8b45e92ce1652b5d98174a6dca.tar.xz
Merge branch 'maint'
Diffstat (limited to 'src/pacman/callback.c')
-rw-r--r--src/pacman/callback.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index 59b40643..92a31f16 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -137,11 +137,9 @@ static void fill_progress(const int bar_percent, const int disp_percent,
}
printf("]");
}
- /* print percent after progress bar */
+ /* print display percent after progress bar */
if(proglen > 5) {
- /* show total download percent if option is enabled */
- int p = config->totaldownload ? disp_percent : bar_percent;
- printf(" %3d%%", p);
+ printf(" %3d%%", disp_percent);
}
if(bar_percent == 100) {
@@ -435,6 +433,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;
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;
@@ -450,6 +449,12 @@ 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;
+ }
+
+ if(totaldownload) {
xfered = list_xfered + file_xfered;
total = list_total;
} else {
@@ -462,8 +467,7 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total)
if(file_xfered == 0) {
/* set default starting values, ensure we only call this once
* if TotalDownload is enabled */
- if(!(config->totaldownload)
- || (config->totaldownload && list_xfered == 0)) {
+ if(!totaldownload || (totaldownload && list_xfered == 0)) {
gettimeofday(&initial_time, NULL);
xfered_last = (off_t)0;
rate_last = 0.0;
@@ -500,7 +504,7 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total)
file_percent = (int)((float)file_xfered) / ((float)file_total) * 100;
- if(config->totaldownload && list_total) {
+ if(totaldownload) {
total_percent = (int)((float)list_xfered + file_xfered) /
((float)list_total) * 100;
@@ -581,7 +585,11 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total)
free(fname);
free(wcfname);
- fill_progress(file_percent, total_percent, getcols() - infolen);
+ if(totaldownload) {
+ fill_progress(file_percent, total_percent, getcols() - infolen);
+ } else {
+ fill_progress(file_percent, file_percent, getcols() - infolen);
+ }
return;
}