summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-01-09 20:47:47 -0600
committerDan McGee <dan@archlinux.org>2011-01-10 10:50:03 -0600
commit842cbc9ea4036036cf00b3b2eeccc11ad531cd2e (patch)
tree9f9a6e1d9d78a5477e3f2e83dcad287e87860389
parentd03b57f459fb9ab9288991a70c4e7297a7c1d150 (diff)
downloadpacman-842cbc9ea4036036cf00b3b2eeccc11ad531cd2e.tar.xz
Ensure we use local package when calculating removed size
We were checking if a package existed locally, but then using the incoming package to calculate removed size rather than the currently installed package. Also adjust the local variable in the replaces loop to make it more clear that we are always dealing with local packages here. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--lib/libalpm/diskspace.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c
index b53d272f..bc5f5127 100644
--- a/lib/libalpm/diskspace.c
+++ b/lib/libalpm/diskspace.c
@@ -246,7 +246,6 @@ int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local)
size_t replaces = 0, current = 0, numtargs;
int abort = 0;
alpm_list_t *targ;
- pmpkg_t *pkg;
numtargs = alpm_list_count(trans->add);
mount_points = mount_point_list();
@@ -259,24 +258,27 @@ int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local)
if(replaces) {
numtargs += replaces;
for(targ = trans->remove; targ; targ = targ->next, current++) {
+ pmpkg_t *local_pkg;
int percent = (current * 100) / numtargs;
PROGRESS(trans, PM_TRANS_PROGRESS_DISKSPACE_START, "", percent,
numtargs, current);
- pkg = targ->data;
- calculate_removed_size(mount_points, pkg);
+ local_pkg = targ->data;
+ calculate_removed_size(mount_points, local_pkg);
}
}
for(targ = trans->add; targ; targ = targ->next, current++) {
+ pmpkg_t *pkg, *local_pkg;
int percent = (current * 100) / numtargs;
PROGRESS(trans, PM_TRANS_PROGRESS_DISKSPACE_START, "", percent,
numtargs, current);
pkg = targ->data;
/* is this package already installed? */
- if(_alpm_db_get_pkgfromcache(db_local, pkg->name)) {
- calculate_removed_size(mount_points, pkg);
+ local_pkg = _alpm_db_get_pkgfromcache(db_local, pkg->name);
+ if(local_pkg) {
+ calculate_removed_size(mount_points, local_pkg);
}
calculate_installed_size(mount_points, pkg);