summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
authorJonathan Conder <j@skurvy.no-ip.org>2010-05-06 00:07:37 +0200
committerDan McGee <dan@archlinux.org>2010-05-06 01:15:52 +0200
commitdf99495b826eab9f25ceeb8f2643565af8818c20 (patch)
tree294f093f72bdf827df0f3ef439b291e2783d318c /lib/libalpm
parentd485c0370f554758a28eff2cc32b2cc9c72a4604 (diff)
downloadpacman-df99495b82.tar.gz
pacman-df99495b82.tar.xz
Compute package download size outside _alpm_sync_prepare
And add a new info level for this piece of data. Signed-off-by: Jonathan Conder <j@skurvy.no-ip.org> Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/db.h3
-rw-r--r--lib/libalpm/sync.c15
2 files changed, 16 insertions, 2 deletions
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) {