Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=13bbddaf3ac1991d7c807dcf02abfdeba634edce

commit 13bbddaf3ac1991d7c807dcf02abfdeba634edce
Author: Michel Hermier <[email protected]>
Date:   Thu Dec 26 09:01:16 2013 +0100

pacman: Use pacman_download_end to compute total download time. Use tell == fsz 
to avoid rounding errors at end of download to change line.

diff --git a/src/pacman-g2/download.c b/src/pacman-g2/download.c
index f7e02ed..cdab73d 100644
--- a/src/pacman-g2/download.c
+++ b/src/pacman-g2/download.c
@@ -85,13 +85,13 @@ int log_progress(const pmdownload_t *download)
pacman_get_option(PM_OPT_CHOMP, (long *)&chomp);

if(tell == fsz) {
-               time_t now = time(NULL);
-               struct timeval begin;
+               struct timeval begin, end;

pacman_download_avg(download, &rate);
pacman_download_begin(download, &begin);
+               pacman_download_end(download, &end);
/* total download time */
-               eta = difftime(now, begin.tv_sec);
+               eta = difftime(end.tv_sec, begin.tv_sec);
}
rate /= 1024; /* convert to KB/s */
eta_s = eta;
@@ -147,7 +147,7 @@ int log_progress(const pmdownload_t *download)
} else {
printf("] %3d%%  %6lldK  %6.1fK/s  %02d:%02d:%02d\r", pct, (long long)(tell / 
1024), rate, eta_h, eta_m, eta_s);
}
-       if(lastpct != 100 && pct == 100) {
+       if(tell == fsz) {
printf("\n");
}
lastcur = cur;
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to