From 7dfc01b7a630275f444540a4741999d3b58ecf43 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 25 Jan 2012 05:10:24 +0100 Subject: [PATCH] Calculate required/freed size for updates in transactions too. --- lib/transaction_dictionary.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/transaction_dictionary.c b/lib/transaction_dictionary.c index f240483c..bf9fb002 100644 --- a/lib/transaction_dictionary.c +++ b/lib/transaction_dictionary.c @@ -95,10 +95,11 @@ compute_transaction_stats(prop_dictionary_t transd) tsize = 0; /* - * If removing a package, get installed_size from - * pkg's metadata dictionary. + * If removing or updating a package, get installed_size + * from pkg's metadata dictionary. */ - if (strcmp(tract, "remove") == 0) { + if ((strcmp(tract, "remove") == 0) || + (strcmp(tract, "update") == 0)) { pkg_metad = xbps_dictionary_from_metadata_plist(pkgname, XBPS_PKGPROPS); @@ -108,7 +109,9 @@ compute_transaction_stats(prop_dictionary_t transd) "installed_size", &tsize); prop_object_release(pkg_metad); rmsize += tsize; - } else { + } + if ((strcmp(tract, "install") == 0) || + (strcmp(tract, "update") == 0)) { prop_dictionary_get_uint64(obj, "installed_size", &tsize); instsize += tsize; @@ -149,7 +152,9 @@ compute_transaction_stats(prop_dictionary_t transd) } else if (rmsize > instsize) { rmsize -= instsize; instsize = 0; - } + } else + instsize = rmsize = 0; + /* * Add object in transaction dictionary with total installed * size that it will take.