summaryrefslogtreecommitdiff
path: root/src/database.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2013-06-17 17:28:03 +0300
committerTimo Teräs <timo.teras@iki.fi>2013-06-17 17:28:03 +0300
commit656190b0a063686b9bd675bbffe43fbebf4aacab (patch)
tree3f0336fb2080b938fc447ed4c155769be0211fb2 /src/database.c
parentade8d0b4e9c206ab67dc8ef2006e8070011aae83 (diff)
downloadapk-tools-656190b0a063686b9bd675bbffe43fbebf4aacab.tar.gz
apk-tools-656190b0a063686b9bd675bbffe43fbebf4aacab.tar.bz2
apk-tools-656190b0a063686b9bd675bbffe43fbebf4aacab.tar.xz
apk-tools-656190b0a063686b9bd675bbffe43fbebf4aacab.zip
io: get rid of APK_PROGRESS_SCALE
no need to muldiv all the time, just pass the current amount of bytes done, and let callbacks use that directly.
Diffstat (limited to 'src/database.c')
-rw-r--r--src/database.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/src/database.c b/src/database.c
index bdfb5fb..cff38c0 100644
--- a/src/database.c
+++ b/src/database.c
@@ -2133,19 +2133,12 @@ int apk_db_add_repository(apk_database_t _db, apk_blob_t _repository)
return 0;
}
-static void extract_cb(void *_ctx, size_t progress)
+static void extract_cb(void *_ctx, size_t bytes_done)
{
struct install_ctx *ctx = (struct install_ctx *) _ctx;
-
- if (ctx->cb) {
- size_t size = ctx->installed_size;
-
- size += muldiv(progress, ctx->current_file_size, APK_PROGRESS_SCALE);
- if (size > ctx->pkg->installed_size)
- size = ctx->pkg->installed_size;
-
- ctx->cb(ctx->cb_ctx, muldiv(APK_PROGRESS_SCALE, size, ctx->pkg->installed_size));
- }
+ if (!ctx->cb)
+ return;
+ ctx->cb(ctx->cb_ctx, min(ctx->installed_size + bytes_done, ctx->pkg->installed_size));
}
static int apk_db_run_pending_script(struct install_ctx *ctx)
@@ -2256,14 +2249,6 @@ static int apk_db_install_archive_entry(void *_ctx,
if (r != 0)
return r;
- /* Show progress */
- if (ctx->cb) {
- size_t size = ctx->installed_size;
- if (size > pkg->installed_size)
- size = pkg->installed_size;
- ctx->cb(ctx->cb_ctx, muldiv(APK_PROGRESS_SCALE, size, pkg->installed_size));
- }
-
/* Installable entry */
ctx->current_file_size = apk_calc_installed_size(ae->size);
if (!S_ISDIR(ae->mode)) {