summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNathan Jones <nathanj@insightbb.com>2007-10-19 13:17:54 -0400
committerDan McGee <dan@archlinux.org>2007-10-19 19:30:06 -0500
commitf5b77eb9894ea92a08fac586ddf03e9ba70c3de8 (patch)
tree6cf3e2750522841f1e1fb39d4d5e9c953bd27644 /src
parente472e80c084c5e94fdc15d2f6565c50e65854372 (diff)
downloadpacman-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 'src')
-rw-r--r--src/pacman/query.c2
-rw-r--r--src/pacman/sync.c2
-rw-r--r--src/pacman/util.c12
-rw-r--r--src/pacman/util.h2
4 files changed, 11 insertions, 7 deletions
diff --git a/src/pacman/query.c b/src/pacman/query.c
index 4e4002cf..8a01d829 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -219,7 +219,7 @@ static int query_upgrades(void)
printf(_("Checking for package upgrades... \n"));
if((syncpkgs = alpm_db_get_upgrades()) != NULL) {
- display_targets(syncpkgs);
+ display_targets(syncpkgs, db_local);
return(0);
}
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 6a7d50e7..bf6eed1b 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -601,7 +601,7 @@ int sync_trans(alpm_list_t *targets, int sync_only)
if(!(alpm_trans_get_flags() & PM_TRANS_FLAG_PRINTURIS)) {
int confirm;
- display_targets(packages);
+ display_targets(packages, db_local);
printf("\n");
if(config->op_s_downloadonly) {
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 48f3f1eb..78a359be 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -329,14 +329,15 @@ void list_display(const char *title, const alpm_list_t *list)
* retrieved from a transaction object
*/
/* TODO move to output.c? or just combine util and output */
-void display_targets(const alpm_list_t *syncpkgs)
+void display_targets(const alpm_list_t *syncpkgs, pmdb_t *db_local)
{
char *str;
const alpm_list_t *i, *j;
alpm_list_t *targets = NULL, *to_remove = NULL;
/* TODO these are some messy variable names */
- unsigned long size = 0, isize = 0, rsize = 0, dispsize = 0;
- double mbsize = 0.0, mbisize = 0.0, mbrsize = 0.0, mbdispsize = 0.0;
+ unsigned long size = 0, isize = 0, rsize = 0, dispsize = 0, dlsize = 0;
+ double mbsize = 0.0, mbisize = 0.0, mbrsize = 0.0, mbdispsize = 0.0,
+ mbdlsize = 0.0;
for(i = syncpkgs; i; i = alpm_list_next(i)) {
pmsyncpkg_t *sync = alpm_list_getdata(i);
@@ -361,6 +362,7 @@ void display_targets(const alpm_list_t *syncpkgs)
dispsize = alpm_pkg_get_size(pkg);
size += dispsize;
+ dlsize += alpm_pkg_download_size(pkg, db_local);
isize += alpm_pkg_get_isize(pkg);
/* print the package size with the output if ShowSize option set */
@@ -381,6 +383,7 @@ void display_targets(const alpm_list_t *syncpkgs)
mbsize = size / (1024.0 * 1024.0);
mbisize = isize / (1024.0 * 1024.0);
mbrsize = rsize / (1024.0 * 1024.0);
+ mbdlsize = dlsize / (1024.0 * 1024.0);
/* start displaying information */
printf("\n");
@@ -396,7 +399,8 @@ void display_targets(const alpm_list_t *syncpkgs)
list_display(_("Targets:"), targets);
printf("\n");
- printf(_("Total Package Size: %.2f MB\n"), mbsize);
+ printf(_("Total Package Size: %.2f MB\n"), mbsize);
+ printf(_("Total Download Size: %.2f MB\n"), mbdlsize);
/* TODO because all pkgs don't include isize, this is a crude hack */
if(mbisize > mbsize) {
diff --git a/src/pacman/util.h b/src/pacman/util.h
index f3171caf..876f8175 100644
--- a/src/pacman/util.h
+++ b/src/pacman/util.h
@@ -47,7 +47,7 @@ char *strtoupper(char *str);
char *strtrim(char *str);
char *strreplace(const char *str, const char *needle, const char *replace);
void list_display(const char *title, const alpm_list_t *list);
-void display_targets(const alpm_list_t *syncpkgs);
+void display_targets(const alpm_list_t *syncpkgs, pmdb_t *db_local);
int yesno(char *fmt, ...);
int pm_printf(pmloglevel_t level, const char *format, ...) __attribute__((format(printf,2,3)));
int pm_fprintf(FILE *stream, pmloglevel_t level, const char *format, ...) __attribute__((format(printf,3,4)));