From e885d029aaa7d18128fd91b7552fc97834dd1956 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sun, 29 Oct 2017 07:00:36 -0400 Subject: [PATCH] bin/delta-compilation: Add a "progress bar" for bsdiff generation It's the slowest part, let's show admins something. This "update every 10%" code was copied from the fsck command; obviously a better approach would be "progress every N seconds" but doing that somewhat accurately requires making things async; not worth it here yet. Closes: #1314 Approved by: jlebon --- .../ostree-repo-static-delta-compilation.c | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/libostree/ostree-repo-static-delta-compilation.c b/src/libostree/ostree-repo-static-delta-compilation.c index 19272984..93a191a0 100644 --- a/src/libostree/ostree-repo-static-delta-compilation.c +++ b/src/libostree/ostree-repo-static-delta-compilation.c @@ -1145,18 +1145,27 @@ generate_delta_lowlatency (OstreeRepo *repo, /* Now do bsdiff'ed objects */ - g_hash_table_iter_init (&hashiter, bsdiff_optimized_content_objects); - while (g_hash_table_iter_next (&hashiter, &key, &value)) + const guint n_bsdiff = g_hash_table_size (bsdiff_optimized_content_objects); + if (n_bsdiff > 0) { - const char *checksum = key; - ContentBsdiff *bsdiff = value; + const guint mod = n_bsdiff / 10; + g_hash_table_iter_init (&hashiter, bsdiff_optimized_content_objects); + while (g_hash_table_iter_next (&hashiter, &key, &value)) + { + const char *checksum = key; + ContentBsdiff *bsdiff = value; - if (!process_one_bsdiff (repo, builder, ¤t_part, - checksum, bsdiff, - cancellable, error)) - return FALSE; + if (opts & DELTAOPT_FLAG_VERBOSE && + (mod == 0 || builder->n_bsdiff % mod == 0)) + g_printerr ("processing bsdiff: [%u/%u]\n", builder->n_bsdiff, n_bsdiff); - builder->n_bsdiff++; + if (!process_one_bsdiff (repo, builder, ¤t_part, + checksum, bsdiff, + cancellable, error)) + return FALSE; + + builder->n_bsdiff++; + } } /* Scan for large objects, so we can fall back to plain HTTP-based