Calculate properly required/freed size in transactions.

This commit is contained in:
Juan RP 2012-01-25 04:56:54 +01:00
parent ff0b9b9b59
commit 1a73b93d63
2 changed files with 35 additions and 34 deletions

View File

@ -185,7 +185,7 @@ show_transaction_sizes(struct transaction *trans)
"%s\n", strerror(errno)); "%s\n", strerror(errno));
return -1; return -1;
} }
printf("Total removed size:\t%6s\n", size); printf("Total freed size:\t%6s\n", size);
} }
printf("\n"); printf("\n");

View File

@ -75,7 +75,9 @@ compute_transaction_stats(prop_dictionary_t transd)
* Count number of pkgs to be removed, configured, * Count number of pkgs to be removed, configured,
* installed and updated. * installed and updated.
*/ */
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract); prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
if (strcmp(tract, "install") == 0) if (strcmp(tract, "install") == 0)
inst_pkgcnt++; inst_pkgcnt++;
else if (strcmp(tract, "update") == 0) else if (strcmp(tract, "update") == 0)
@ -84,38 +86,7 @@ compute_transaction_stats(prop_dictionary_t transd)
cf_pkgcnt++; cf_pkgcnt++;
else if (strcmp(tract, "remove") == 0) else if (strcmp(tract, "remove") == 0)
rm_pkgcnt++; rm_pkgcnt++;
}
if (inst_pkgcnt &&
!prop_dictionary_set_uint32(transd, "total-install-pkgs",
inst_pkgcnt)) {
rv = EINVAL;
goto out;
}
if (up_pkgcnt &&
!prop_dictionary_set_uint32(transd, "total-update-pkgs",
up_pkgcnt)) {
rv = EINVAL;
goto out;
}
if (cf_pkgcnt &&
!prop_dictionary_set_uint32(transd, "total-configure-pkgs",
cf_pkgcnt)) {
rv = EINVAL;
goto out;
}
if (rm_pkgcnt &&
!prop_dictionary_set_uint32(transd, "total-remove-pkgs",
rm_pkgcnt)) {
rv = EINVAL;
goto out;
}
prop_object_iterator_reset(iter);
while ((obj = prop_object_iterator_next(iter)) != NULL) {
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
/* /*
* Only process pkgs to be installed or updated. * Only process pkgs to be installed or updated.
*/ */
@ -146,9 +117,39 @@ compute_transaction_stats(prop_dictionary_t transd)
dlsize += tsize; dlsize += tsize;
} }
} }
/* installed - removed */
if (rmsize > 0 && instsize > 0) if (inst_pkgcnt &&
!prop_dictionary_set_uint32(transd, "total-install-pkgs",
inst_pkgcnt)) {
rv = EINVAL;
goto out;
}
if (up_pkgcnt &&
!prop_dictionary_set_uint32(transd, "total-update-pkgs",
up_pkgcnt)) {
rv = EINVAL;
goto out;
}
if (cf_pkgcnt &&
!prop_dictionary_set_uint32(transd, "total-configure-pkgs",
cf_pkgcnt)) {
rv = EINVAL;
goto out;
}
if (rm_pkgcnt &&
!prop_dictionary_set_uint32(transd, "total-remove-pkgs",
rm_pkgcnt)) {
rv = EINVAL;
goto out;
}
if (instsize > rmsize) {
instsize -= rmsize; instsize -= rmsize;
rmsize = 0;
} else if (rmsize > instsize) {
rmsize -= instsize;
instsize = 0;
}
/* /*
* Add object in transaction dictionary with total installed * Add object in transaction dictionary with total installed
* size that it will take. * size that it will take.