summaryrefslogtreecommitdiff
path: root/src/ostree/ot-builtin-pull-local.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2016-05-01 14:22:52 -0400
committerColin Walters (automation) <walters+githubbot@verbum.org>2016-05-02 11:41:00 +0000
commita6c731f6e7d1014aab5989c98a6432d28080905b (patch)
tree7bd80f0c1024770e1eb5cbdb304daa2492e02170 /src/ostree/ot-builtin-pull-local.c
parent831e9dcdeac28b56c29e84f58ae90fb70e73626c (diff)
downloadostree-a6c731f6e7d1014aab5989c98a6432d28080905b.tar.gz
libglnx porting: Migrate from GSConsole
To GLnxConsoleRef. There were some subtleties here, for example we used to reference `GSConsole` inside the progress changed function, which at first seems like an ABI hazard, because e.g. rpm-ostree or xdg-app could still be passing a `GSConsole` instance there. Luckily, it turns out to be compatible to just start calling libglnx here. Another issue was that due to libglnx's use of the cleanup function, we needed to ensure we always called `ostree_async_progress_finish()` *before* the cleanup function was invoked. Closes: #280 Approved by: giuseppe
Diffstat (limited to 'src/ostree/ot-builtin-pull-local.c')
-rw-r--r--src/ostree/ot-builtin-pull-local.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/ostree/ot-builtin-pull-local.c b/src/ostree/ot-builtin-pull-local.c
index 36057ec6..7fb6f03a 100644
--- a/src/ostree/ot-builtin-pull-local.c
+++ b/src/ostree/ot-builtin-pull-local.c
@@ -55,7 +55,6 @@ ostree_builtin_pull_local (int argc, char **argv, GCancellable *cancellable, GEr
glnx_unref_object OstreeRepo *repo = NULL;
int i;
const char *src_repo_arg;
- GSConsole *console = NULL;
g_autofree char *src_repo_uri = NULL;
glnx_unref_object OstreeAsyncProgress *progress = NULL;
g_autoptr(GPtrArray) refs_to_fetch = NULL;
@@ -132,14 +131,11 @@ ostree_builtin_pull_local (int argc, char **argv, GCancellable *cancellable, GEr
g_ptr_array_add (refs_to_fetch, NULL);
}
- console = gs_console_get ();
- if (console)
- {
- gs_console_begin_status_line (console, "", NULL, NULL);
- progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, console);
- }
-
{ GVariantBuilder builder;
+ g_auto(GLnxConsoleRef) console = { 0, };
+
+ glnx_console_lock (&console);
+
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_add (&builder, "{s@v}", "flags",
@@ -158,17 +154,21 @@ ostree_builtin_pull_local (int argc, char **argv, GCancellable *cancellable, GEr
g_variant_builder_add (&builder, "{s@v}", "depth",
g_variant_new_variant (g_variant_new_int32 (opt_depth)));
+ if (console.is_tty)
+ progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, &console);
+
if (!ostree_repo_pull_with_options (repo, src_repo_uri,
g_variant_builder_end (&builder),
progress,
cancellable, error))
goto out;
+
+ if (progress)
+ ostree_async_progress_finish (progress);
}
ret = TRUE;
out:
- if (progress)
- ostree_async_progress_finish (progress);
if (context)
g_option_context_free (context);
if (repo)