[ostree] pull: Tweak status line again, do what git does



commit 2bcb024824ff5aa903bb6e8e8d4bb701c640f568
Author: Colin Walters <walters verbum org>
Date:   Wed Jul 24 18:20:19 2013 -0400

    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 files changed, 18 insertions(+), 15 deletions(-)
---
diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c
index a270d1c..8837b37 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_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_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;
   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);
-
-      fetcher_status = ostree_fetcher_query_state_text (pull_data->fetcher);
-      g_string_append (status, fetcher_status);
+      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;
+
+      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);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]