summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/sync.c
diff options
context:
space:
mode:
authorNathan Jones <nathanj@insightbb.com>2007-11-10 01:54:19 +0100
committerDan McGee <dan@archlinux.org>2007-11-11 16:46:13 +0100
commit8ec27835f40e3df1ce409bc3d913587c474a30c3 (patch)
treee7d1c943ab3c37662079ef5e974c61dcd5807139 /lib/libalpm/sync.c
parentb206af78e0e6d2ff3324f3b2dc333d1b4e54f5b9 (diff)
downloadpacman-8ec27835f40e3df1ce409bc3d913587c474a30c3.tar.gz
pacman-8ec27835f40e3df1ce409bc3d913587c474a30c3.tar.xz
Implement TotalDownload option.
Setting this option will change the download progress to show the amount downloaded, download rate, ETA, and download percent of the entire download list rather than per each individual file. The progress bar is still based on the completion of the current file regardless if the TotalDownload option is set. This closes FS#7205. Signed-off-by: Nathan Jones <nathanj@insightbb.com> Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/sync.c')
-rw-r--r--lib/libalpm/sync.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 10a72a7b..40766914 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -990,6 +990,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
pmtrans_t *tr = NULL;
int replaces = 0, retval = 0;
const char *cachedir = NULL;
+ int dltotal = 0, dl = 0;
ALPM_LOG_FUNC;
@@ -998,6 +999,15 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
cachedir = _alpm_filecache_setup();
trans->state = STATE_DOWNLOADING;
+
+ /* Sum up the download sizes. This has to be in its own loop because
+ * the download loop is grouped by db. */
+ for(j = trans->packages; j; j = j->next) {
+ pmsyncpkg_t *sync = j->data;
+ pmpkg_t *spkg = sync->pkg;
+ dltotal += alpm_pkg_download_size(spkg, db_local);
+ }
+
/* group sync records by repository and download */
for(i = handle->dbs_sync; i; i = i->next) {
pmdb_t *current = i->data;
@@ -1061,7 +1071,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
if(files) {
EVENT(trans, PM_TRANS_EVT_RETRIEVE_START, current->treename, NULL);
- if(_alpm_downloadfiles(current->servers, cachedir, files)) {
+ if(_alpm_downloadfiles(current->servers, cachedir, files, &dl, dltotal)) {
_alpm_log(PM_LOG_WARNING, _("failed to retrieve some files from %s\n"),
current->treename);
RET_ERR(PM_ERR_RETRIEVE, -1);