diff options
author | Sören Tempel <soeren+git@soeren-tempel.net> | 2019-06-05 15:01:35 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2020-01-05 23:26:50 +0200 |
commit | 7d930f942cf9989e53381a05bce7de99b2d2aa9c (patch) | |
tree | efaf5037b0e7e157f98fffb826ae255a65c07fdd /src | |
parent | a6039e38a42cc977f7f9da3dcc69e7f98317b4c1 (diff) | |
download | apk-tools-7d930f942cf9989e53381a05bce7de99b2d2aa9c.tar.gz apk-tools-7d930f942cf9989e53381a05bce7de99b2d2aa9c.tar.bz2 apk-tools-7d930f942cf9989e53381a05bce7de99b2d2aa9c.tar.xz apk-tools-7d930f942cf9989e53381a05bce7de99b2d2aa9c.zip |
commit: make use of the apk_get_human_unit function
Diffstat (limited to 'src')
-rw-r--r-- | src/commit.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/commit.c b/src/commit.c index 4a94ff5..a441927 100644 --- a/src/commit.c +++ b/src/commit.c @@ -261,8 +261,9 @@ int apk_solver_commit_changeset(struct apk_database *db, { struct progress prog; struct apk_change *change; - char buf[32], size_unit; - ssize_t size_diff = 0; + char buf[32]; + const char *size_unit; + off_t humanized, size_diff = 0; int r, errors = 0; if (apk_db_check_world(db, world) != 0) { @@ -279,15 +280,11 @@ int apk_solver_commit_changeset(struct apk_database *db, foreach_array_item(change, changeset->changes) { count_change(change, &prog.total); if (change->new_pkg) - size_diff += change->new_pkg->installed_size / 1024; + size_diff += change->new_pkg->installed_size; if (change->old_pkg) - size_diff -= change->old_pkg->installed_size / 1024; - } - size_unit = 'K'; - if (labs(size_diff) > 10000) { - size_diff /= 1024; - size_unit = 'M'; + size_diff -= change->old_pkg->installed_size; } + size_unit = apk_get_human_size(llabs(size_diff), &humanized); if ((apk_verbosity > 1 || (apk_flags & APK_INTERACTIVE)) && !(apk_flags & APK_SIMULATE)) { @@ -302,8 +299,8 @@ int apk_solver_commit_changeset(struct apk_database *db, "The following packages will be upgraded"); r += dump_packages(changeset, cmp_reinstall, "The following packages will be reinstalled"); - printf("After this operation, %zd %ciB of %s.\n", - (size_diff < 0) ? -size_diff : size_diff, + printf("After this operation, %lld %s of %s.\n", + (long long)humanized, size_unit, (size_diff < 0) ? "disk space will be freed" : |