From 2bcb024824ff5aa903bb6e8e8d4bb701c640f568 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 24 Jul 2013 18:20:19 -0400 Subject: [PATCH] pull: Tweak status line again, do what git does Almost, we don't have bytes transferred. And we lie about percentages since as metadata comes in the total number of objects to fetch goes up. --- src/libostree/ostree-repo-pull.c | 33 +++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c index a270d1c0..8837b378 100644 --- a/src/libostree/ostree-repo-pull.c +++ b/src/libostree/ostree-repo-pull.c @@ -194,26 +194,29 @@ uri_fetch_update_status (gpointer user_data) status = g_string_new (""); - if (!pull_data->metadata_scan_idle) - g_string_append_printf (status, "scan: %u; ", - g_atomic_int_get (&pull_data->n_scanned_metadata)); - - outstanding_stages = pull_data->n_outstanding_content_stage_requests + pull_data->n_outstanding_metadata_stage_requests; - if (outstanding_stages > 0) - g_string_append_printf (status, "writing: %u; ", outstanding_stages); - outstanding_fetches = pull_data->n_outstanding_content_fetches + pull_data->n_outstanding_metadata_fetches; + outstanding_stages = pull_data->n_outstanding_content_stage_requests + pull_data->n_outstanding_metadata_stage_requests; + if (outstanding_fetches) { - g_string_append_printf (status, "fetch: %u/%u meta %u/%u; ", - pull_data->n_fetched_metadata, - pull_data->n_requested_metadata, - pull_data->n_fetched_content, - pull_data->n_requested_content); + guint64 bytes_transferred = ostree_fetcher_bytes_transferred (pull_data->fetcher); + guint fetched = pull_data->n_fetched_metadata + pull_data->n_fetched_content; + guint requested = pull_data->n_requested_metadata + pull_data->n_requested_content; + gs_free char *formatted_bytes_transferred = NULL; - fetcher_status = ostree_fetcher_query_state_text (pull_data->fetcher); - g_string_append (status, fetcher_status); + formatted_bytes_transferred = g_format_size_full (bytes_transferred, 0); + + g_string_append_printf (status, "Receiving objects: %u%% (%u/%u) %s", + (guint)((((double)fetched) / requested) * 100), + fetched, requested, formatted_bytes_transferred); } + else if (outstanding_stages > 0) + g_string_append_printf (status, "Writing objects: %u", outstanding_stages); + else if (!pull_data->metadata_scan_idle) + g_string_append_printf (status, "Scanning metadata: %u", + g_atomic_int_get (&pull_data->n_scanned_metadata)); + else + g_string_append_printf (status, "Idle"); gs_console_begin_status_line (gs_console_get (), status->str, NULL, NULL);