[ostree] pull-local: Output status even in non-tty case
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] pull-local: Output status even in non-tty case
- Date: Thu, 21 Feb 2013 17:48:01 +0000 (UTC)
commit 852143827328c58f709d105bd2191a99e9303165
Author: Colin Walters <walters verbum org>
Date: Thu Feb 21 08:54:13 2013 -0500
pull-local: Output status even in non-tty case
This way I can see progress when running builddisks.
src/ostree/ot-builtin-pull-local.c | 33 +++++++++++++++------------------
1 files changed, 15 insertions(+), 18 deletions(-)
---
diff --git a/src/ostree/ot-builtin-pull-local.c b/src/ostree/ot-builtin-pull-local.c
index 81c6d88..5c1106b 100644
--- a/src/ostree/ot-builtin-pull-local.c
+++ b/src/ostree/ot-builtin-pull-local.c
@@ -40,6 +40,7 @@ typedef struct {
int n_objects_to_check;
volatile int n_objects_checked;
volatile int n_objects_copied;
+ GSConsole *console;
} OtLocalCloneData;
static gboolean
@@ -141,7 +142,10 @@ idle_print_status (gpointer user_data)
g_atomic_int_get (&data->n_objects_checked),
data->n_objects_to_check,
g_atomic_int_get (&data->n_objects_copied));
- gs_console_begin_status_line (gs_console_get (), str, NULL, NULL);
+ if (data->console)
+ gs_console_begin_status_line (data->console, str, NULL, NULL);
+ else
+ g_print ("%s\n", str);
return TRUE;
}
@@ -269,26 +273,19 @@ ostree_builtin_pull_local (int argc, char **argv, GFile *repo_path, GError **err
if (data->n_objects_to_check > 0)
{
- console = gs_console_get ();
+ data->console = gs_console_get ();
+
+ if (data->console)
+ gs_console_begin_status_line (console, "", NULL, NULL);
+
+ g_timeout_add_seconds (1, idle_print_status, data);
+ idle_print_status (data);
- if (console)
- {
- gs_console_begin_status_line (console, "", NULL, NULL);
- g_timeout_add_seconds (1, idle_print_status, data);
- idle_print_status (data);
- }
- else
- {
- g_print ("Copying %d objects...\n", data->n_objects_to_check);
- }
-
g_main_loop_run (data->loop);
- if (console)
- {
- idle_print_status (data);
- gs_console_end_status_line (console, NULL, NULL);
- }
+ idle_print_status (data);
+ if (data->console)
+ gs_console_end_status_line (console, NULL, NULL);
}
if (!ostree_repo_commit_transaction (data->dest_repo, NULL, error))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]