diff options
author | Nathan Jones <nathanj@insightbb.com> | 2007-10-19 19:17:54 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2007-10-20 02:30:06 +0200 |
commit | f5b77eb9894ea92a08fac586ddf03e9ba70c3de8 (patch) | |
tree | 6cf3e2750522841f1e1fb39d4d5e9c953bd27644 /lib/libalpm/sync.c | |
parent | e472e80c084c5e94fdc15d2f6565c50e65854372 (diff) | |
download | pacman-f5b77eb9894ea92a08fac586ddf03e9ba70c3de8.tar.gz pacman-f5b77eb9894ea92a08fac586ddf03e9ba70c3de8.tar.xz |
Add download size to target list.
This displays the download size, taking into account delta files and
cached files.
This closes FS#4182.
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.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index d5f65001..3e12ffb5 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -749,6 +749,40 @@ static alpm_list_t *pkg_upgrade_delta_path(pmpkg_t *newpkg, pmdb_t *db_local) return(ret); } +/** Returns the size of the files that will be downloaded to install a + * package. + * + * @param newpkg the new package to upgrade to + * @param db_local the local database + * + * @return the size of the download + */ +unsigned long SYMEXPORT alpm_pkg_download_size(pmpkg_t *newpkg, pmdb_t *db_local) +{ + char *fpath = _alpm_filecache_find(alpm_pkg_get_filename(newpkg)); + unsigned long size = 0; + + if(fpath) { + size = 0; + } else if(handle->usedelta) { + alpm_list_t *deltas = pkg_upgrade_delta_path(newpkg, db_local); + + if(deltas) { + size = _alpm_delta_path_size_uncached(deltas); + } else { + size = alpm_pkg_get_size(newpkg); + } + + alpm_list_free(deltas); + } else { + size = alpm_pkg_get_size(newpkg); + } + + FREE(fpath); + + return(size); +} + /** Applies delta files to create an upgraded package file. * * All intermediate files are deleted, leaving only the starting and |