From 426a12686e6e6dcce11616c774176c01ad0985f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Wed, 12 Jun 2013 08:45:29 +0300 Subject: solver: rewrite as deductive solver -- per name flags Handle properly per-name preference flags, and add test cases for testing those via fix applet. --- src/commit.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/commit.c') diff --git a/src/commit.c b/src/commit.c index 660aab9e72..2c1d4b5729 100644 --- a/src/commit.c +++ b/src/commit.c @@ -104,15 +104,16 @@ struct apk_stats { static void count_change(struct apk_change *change, struct apk_stats *stats) { - if (change->new_pkg != change->old_pkg) { + if (change->new_pkg != change->old_pkg || change->reinstall) { if (change->new_pkg != NULL) { stats->bytes += change->new_pkg->installed_size; - stats->packages ++; + stats->packages++; } if (change->old_pkg != NULL) - stats->packages ++; + stats->packages++; stats->changes++; - } else if (change->reinstall || change->new_repository_tag != change->old_repository_tag) { + } else if (change->new_repository_tag != change->old_repository_tag) { + stats->packages++; stats->changes++; } } @@ -157,12 +158,16 @@ static void update_progress(struct progress *prog, size_t percent, int force) static void progress_cb(void *ctx, size_t pkg_percent) { struct progress *prog = (struct progress *) ctx; - size_t partial = 0, percent; + size_t partial = 0, percent, total; if (prog->pkg != NULL) partial = muldiv(pkg_percent, prog->pkg->installed_size, APK_PROGRESS_SCALE); - percent = muldiv(100, prog->done.bytes + prog->done.packages + partial, - prog->total.bytes + prog->total.packages); + total = prog->total.bytes + prog->total.packages; + if (total > 0) + percent = muldiv(100, prog->done.bytes + prog->done.packages + partial, + prog->total.bytes + prog->total.packages); + else + percent = 0; update_progress(prog, percent, pkg_percent == 0); } -- cgit v1.2.3