diff -u -r pacman-3.0.4/src/pacman/downloadprog.c pacman-3.0.4-diff/src/pacman/downloadprog.c --- pacman-3.0.4/src/pacman/downloadprog.c 2007-03-06 04:18:15.000000000 +0100 +++ pacman-3.0.4-diff/src/pacman/downloadprog.c 2007-05-16 03:06:17.000000000 +0200 @@ -1,8 +1,8 @@ /* * downloadprog.c - * + * * Copyright (c) 2002-2006 by Judd Vinet - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ @@ -53,11 +53,10 @@ void log_progress(const char *filename, int xfered, int total) { const int infolen = 50; - char *fname, *p; + char *fname, *p; float rate = 0.0, timediff = 0.0, f_xfered = 0.0; unsigned int eta_h = 0, eta_m = 0, eta_s = 0; - int percent; char rate_size = 'K', xfered_size = 'K'; if(config->noprogressbar) { @@ -110,8 +109,6 @@ xfered_last = xfered; } - percent = (int)((float)xfered) / ((float)total) * 100; - /* fix up time for display */ eta_h = eta_s / 3600; eta_s -= eta_h * 3600; @@ -151,16 +148,16 @@ xfered_size = 'G'; /* I should seriously hope that archlinux packages never break * the 9999.9GB mark... we'd have more serious problems than the progress - * bar in pacman */ + * bar in pacman */ } } - printf(" %-*s %6.1f%c %#6.1f%c/s %02u:%02u:%02u", FILENAME_TRIM_LEN, fname, + printf(" %-*s %6.1f%c %#6.1f%c/s %02u:%02u:%02u", FILENAME_TRIM_LEN, fname, f_xfered, xfered_size, rate, rate_size, eta_h, eta_m, eta_s); free(fname); - - fill_progress(percent, getcols() - infolen); + + fill_progress(total, getcols() - infolen, xfered); return; } diff -u -r pacman-3.0.4/src/pacman/trans.c pacman-3.0.4-diff/src/pacman/trans.c --- pacman-3.0.4/src/pacman/trans.c 2007-03-19 04:12:01.000000000 +0100 +++ pacman-3.0.4-diff/src/pacman/trans.c 2007-05-14 04:01:21.000000000 +0200 @@ -372,7 +372,7 @@ free(wcopr); /* call refactored fill progress function */ - fill_progress(percent, getcols() - infolen); + fill_progress(percent, getcols() - infolen, 0); if(percent >= 100) { set_output_padding(0); /* restore padding */ diff -u -r pacman-3.0.4/src/pacman/util.c pacman-3.0.4-diff/src/pacman/util.c --- pacman-3.0.4/src/pacman/util.c 2007-03-15 00:05:28.000000000 +0100 +++ pacman-3.0.4-diff/src/pacman/util.c 2007-05-16 00:04:03.000000000 +0200 @@ -51,7 +51,7 @@ #include "log.h" extern config_t *config; - +float mmbsize; // XXX yeah i will burn in hell!! /* gets the current screen column width */ int getcols() { @@ -306,6 +306,7 @@ mbisize = (double)(isize) / (1024.0 * 1024.0); mbrsize = (double)(rsize) / (1024.0 * 1024.0); + if(to_remove) { MSG(NL, "\n"); /* TODO ugly hack. printing a single NL should be easy */ list_display(_("Remove:"), to_remove); @@ -327,8 +328,10 @@ if(mbsize < 0.1) { mbsize = 0.1; } + + mmbsize = mbsize; MSG(NL, _("\nTotal Package Size: %.2f MB\n"), mbsize); - + if(mbisize > mbsize) { /*round up if size is really small */ if(mbisize < 0.1) { @@ -377,14 +380,16 @@ } /* refactored from cb_trans_progress */ -void fill_progress(const int percent, const int proglen) +void fill_progress(const int total, const int proglen, const int xfered) { + int percent; + percent = (int)((float)xfered) / ((float)total) * 100; + const unsigned short chomp = alpm_option_get_chomp(); const unsigned int hashlen = proglen - 8; const unsigned int hash = percent * hashlen / 100; - static unsigned int lasthash = 0, mouth = 0; + static unsigned int lasthash = 0, mouth = 0, gtotal = 0; unsigned int i; - /* printf("\ndebug: proglen: %i\n", proglen); DEBUG*/ if(percent == 0) { @@ -431,11 +436,22 @@ printf("]"); } /* print percent after progress bar */ - if(proglen > 5) { - printf(" %3d%%", percent); + if(xfered) { + if(mmbsize) { + int gpercent; + gpercent = (int)((((float)(gtotal + xfered) / (1024.0 * 1024.0)) / (float)(mmbsize)) * 100); + if(proglen > 5) { + printf(" %3d%%", gpercent); + } + } else if(proglen > 5) { + printf(" %3d%%", percent); + } } + if(percent == 100) { + if(mmbsize) + gtotal += total; printf("\n"); } else { printf("\r"); diff -u -r pacman-3.0.4/src/pacman/util.h pacman-3.0.4-diff/src/pacman/util.h --- pacman-3.0.4/src/pacman/util.h 2007-03-15 00:05:28.000000000 +0100 +++ pacman-3.0.4-diff/src/pacman/util.h 2007-05-14 03:59:27.000000000 +0200 @@ -60,7 +60,7 @@ void list_display(const char *title, alpm_list_t *list); void display_targets(alpm_list_t *syncpkgs); float get_update_timediff(int first_call); -void fill_progress(const int percent, const int proglen); +void fill_progress(const int percent, const int proglen, const int xfered); #endif /* _PM_UTIL_H */