commit: print download size of packages in interactive mode

ref #10788
cute-signatures
Timo Teräs 2021-11-15 14:37:25 +02:00
parent 16e0f6df7f
commit 25c152e653
1 changed files with 12 additions and 3 deletions

View File

@ -267,7 +267,7 @@ int apk_solver_commit_changeset(struct apk_database *db,
struct apk_change *change;
char buf[32];
const char *size_unit;
off_t humanized, size_diff = 0;
off_t humanized, size_diff = 0, download_size = 0;
int r, errors = 0;
assert(world);
@ -283,12 +283,15 @@ int apk_solver_commit_changeset(struct apk_database *db,
/* Count what needs to be done */
foreach_array_item(change, changeset->changes) {
count_change(change, &prog.total);
if (change->new_pkg)
if (change->new_pkg) {
size_diff += change->new_pkg->installed_size;
if (change->new_pkg != change->old_pkg &&
!(change->new_pkg->repos & db->local_repos))
download_size += change->new_pkg->size;
}
if (change->old_pkg)
size_diff -= change->old_pkg->installed_size;
}
size_unit = apk_get_human_size(llabs(size_diff), &humanized);
if ((apk_out_verbosity(out) > 1 || (db->ctx->flags & APK_INTERACTIVE)) &&
!(db->ctx->flags & APK_SIMULATE)) {
@ -303,6 +306,12 @@ int apk_solver_commit_changeset(struct apk_database *db,
"The following packages will be upgraded");
r += dump_packages(out, changeset, cmp_reinstall,
"The following packages will be reinstalled");
if (download_size) {
size_unit = apk_get_human_size(download_size, &humanized);
printf("Need to download %lld %s of packages.\n",
(long long)humanized, size_unit);
}
size_unit = apk_get_human_size(llabs(size_diff), &humanized);
printf("After this operation, %lld %s of %s.\n",
(long long)humanized,
size_unit,