From df99495b826eab9f25ceeb8f2643565af8818c20 Mon Sep 17 00:00:00 2001 From: Jonathan Conder Date: Thu, 6 May 2010 10:07:37 +1200 Subject: Compute package download size outside _alpm_sync_prepare And add a new info level for this piece of data. Signed-off-by: Jonathan Conder Signed-off-by: Dan McGee --- lib/libalpm/db.h | 3 ++- lib/libalpm/sync.c | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'lib/libalpm') diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h index 9b78ad42..1851b5c9 100644 --- a/lib/libalpm/db.h +++ b/lib/libalpm/db.h @@ -34,7 +34,8 @@ typedef enum _pmdbinfrq_t { INFRQ_FILES = (1 << 3), INFRQ_SCRIPTLET = (1 << 4), INFRQ_DELTAS = (1 << 5), - /* ALL should be sum of all above */ + INFRQ_DSIZE = (1 << 6), + /* ALL should be info stored in the package or database */ INFRQ_ALL = 0x3F } pmdbinfrq_t; diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 49969204..6bc0b37c 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -356,6 +356,7 @@ static int compute_download_size(pmpkg_t *newpkg) off_t size = 0; if(newpkg->origin == PKG_FROM_FILE) { + newpkg->infolevel |= INFRQ_DSIZE; newpkg->download_size = 0; return(0); } @@ -392,6 +393,7 @@ static int compute_download_size(pmpkg_t *newpkg) _alpm_log(PM_LOG_DEBUG, "setting download size %jd for pkg %s\n", (intmax_t)size, alpm_pkg_get_name(newpkg)); + newpkg->infolevel |= INFRQ_DSIZE; newpkg->download_size = size; return(0); } @@ -649,6 +651,9 @@ cleanup: */ off_t SYMEXPORT alpm_pkg_download_size(pmpkg_t *newpkg) { + if(!(newpkg->infolevel & INFRQ_DSIZE)) { + compute_download_size(newpkg); + } return(newpkg->download_size); } @@ -850,7 +855,15 @@ 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_download_files(files, current->servers, cachedir)) { + errors = _alpm_download_files(files, current->servers, cachedir); + + for(j = trans->add; j; j = j->next) { + pmpkg_t *pkg = j->data; + pkg->infolevel &= ~INFRQ_DSIZE; + pkg->download_size = 0; + } + + if (errors) { _alpm_log(PM_LOG_WARNING, _("failed to retrieve some files from %s\n"), current->treename); if(pm_errno == 0) { -- cgit v1.2.3-24-g4f1b