From f1b5b45af39618bcf39f04abfd2a8edf7cdf45f7 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 21 Jan 2015 14:37:29 -0500 Subject: [PATCH] Factor out summary loading into a function This will make it easier to bring in libsoup --- xdg-app-builtins-repo-contents.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/xdg-app-builtins-repo-contents.c b/xdg-app-builtins-repo-contents.c index bee7f0b3..b55bafae 100644 --- a/xdg-app-builtins-repo-contents.c +++ b/xdg-app-builtins-repo-contents.c @@ -23,6 +23,15 @@ static GOptionEntry options[] = { { NULL } }; +static gboolean +load_contents (const char *uri, char **buffer, gsize *length, GCancellable *cancellable, GError **error) +{ + gs_unref_object GFile *file = NULL; + + file = g_file_new_for_uri (uri); + return g_file_load_contents (file, cancellable, buffer, length, NULL, error); +} + gboolean xdg_app_builtin_repo_contents (int argc, char **argv, GCancellable *cancellable, GError **error) { @@ -38,8 +47,7 @@ xdg_app_builtin_repo_contents (int argc, char **argv, GCancellable *cancellable, int i; const char *repository; gs_free char *url = NULL; - gs_unref_object GFile *repo_file = NULL; - gs_unref_object GFile *summary_file = NULL; + gs_free char *summary_url = NULL; char *buffer; gsize length; @@ -60,9 +68,8 @@ xdg_app_builtin_repo_contents (int argc, char **argv, GCancellable *cancellable, if (!ostree_repo_remote_get_url (repo, repository, &url, error)) goto out; - repo_file = g_file_new_for_uri (url); - summary_file = g_file_get_child (repo_file, "summary"); - if (g_file_load_contents (summary_file, cancellable, &buffer, &length, NULL, NULL)) + summary_url = g_strconcat (url, "/summary", NULL); + if (load_contents (summary_url, &buffer, &length, cancellable, NULL)) { gs_unref_variant GVariant *summary; gs_unref_variant GVariant *ref_list;