summaryrefslogtreecommitdiff
path: root/src/libostree/ostree-repo-finder-avahi.c
diff options
context:
space:
mode:
authorPhilip Withnall <withnall@endlessm.com>2017-09-21 16:00:05 +0100
committerAtomic Bot <atomic-devel@projectatomic.io>2017-09-27 16:38:07 +0000
commit22c1fdfbd320379a09f4a670126bc28cdc383b87 (patch)
treed31c9c1f08f25eb838a37c542ff7e686237d7625 /src/libostree/ostree-repo-finder-avahi.c
parent030d2b1525a49c356210c18f57655afd9f474b4f (diff)
downloadostree-22c1fdfbd320379a09f4a670126bc28cdc383b87.tar.gz
lib/repo: Change resolve_keyring_for_collection() to return a remote
Instead of returning just the keyring filename, return the entire OstreeRemote, which has the keyring filename as one of its members. This will simplify some upcoming changes, and allows slightly improved debug logging. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #1202 Approved by: cgwalters
Diffstat (limited to 'src/libostree/ostree-repo-finder-avahi.c')
-rw-r--r--src/libostree/ostree-repo-finder-avahi.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/libostree/ostree-repo-finder-avahi.c b/src/libostree/ostree-repo-finder-avahi.c
index 4de74c6e..409fcae8 100644
--- a/src/libostree/ostree-repo-finder-avahi.c
+++ b/src/libostree/ostree-repo-finder-avahi.c
@@ -165,28 +165,28 @@ ostree_avahi_browser_event_to_string (AvahiBrowserEvent event)
typedef struct
{
gchar *uri;
- gchar *keyring;
+ OstreeRemote *keyring_remote; /* (owned) */
} UriAndKeyring;
static void
uri_and_keyring_free (UriAndKeyring *data)
{
g_free (data->uri);
- g_free (data->keyring);
+ ostree_remote_unref (data->keyring_remote);
g_free (data);
}
G_DEFINE_AUTOPTR_CLEANUP_FUNC (UriAndKeyring, uri_and_keyring_free)
static UriAndKeyring *
-uri_and_keyring_new (const gchar *uri,
- const gchar *keyring)
+uri_and_keyring_new (const gchar *uri,
+ OstreeRemote *keyring_remote)
{
g_autoptr(UriAndKeyring) data = NULL;
data = g_new0 (UriAndKeyring, 1);
data->uri = g_strdup (uri);
- data->keyring = g_strdup (keyring);
+ data->keyring_remote = ostree_remote_ref (keyring_remote);
return g_steal_pointer (&data);
}
@@ -196,7 +196,7 @@ uri_and_keyring_hash (gconstpointer key)
{
const UriAndKeyring *_key = key;
- return g_str_hash (_key->uri) ^ g_str_hash (_key->keyring);
+ return g_str_hash (_key->uri) ^ g_str_hash (_key->keyring_remote->keyring);
}
static gboolean
@@ -205,7 +205,8 @@ uri_and_keyring_equal (gconstpointer a,
{
const UriAndKeyring *_a = a, *_b = b;
- return g_str_equal (_a->uri, _b->uri) && g_str_equal (_a->keyring, _b->keyring);
+ return (g_str_equal (_a->uri, _b->uri) &&
+ g_str_equal (_a->keyring_remote->keyring, _b->keyring_remote->keyring));
}
/* This must return a valid remote name (suitable for use in a refspec). */
@@ -213,7 +214,7 @@ static gchar *
uri_and_keyring_to_name (UriAndKeyring *data)
{
g_autofree gchar *escaped_uri = g_uri_escape_string (data->uri, NULL, FALSE);
- g_autofree gchar *escaped_keyring = g_uri_escape_string (data->keyring, NULL, FALSE);
+ g_autofree gchar *escaped_keyring = g_uri_escape_string (data->keyring_remote->keyring, NULL, FALSE);
/* FIXME: Need a better separator than `_`, since it’s not escaped in the input. */
g_autofree gchar *out = g_strdup_printf ("%s_%s", escaped_uri, escaped_keyring);
@@ -770,14 +771,15 @@ ostree_avahi_service_build_repo_finder_result (OstreeAvahiService
for (i = 0; i < possible_refs->len; i++)
{
const OstreeCollectionRef *ref = g_ptr_array_index (possible_refs, i);
- g_autofree gchar *keyring = NULL;
g_autoptr(UriAndKeyring) resolved_repo = NULL;
+ g_autoptr(OstreeRemote) keyring_remote = NULL;
/* Look up the GPG keyring for this ref. */
- keyring = ostree_repo_resolve_keyring_for_collection (parent_repo, ref->collection_id,
- cancellable, &error);
+ keyring_remote = ostree_repo_resolve_keyring_for_collection (parent_repo,
+ ref->collection_id,
+ cancellable, &error);
- if (keyring == NULL)
+ if (keyring_remote == NULL)
{
g_debug ("Ignoring ref (%s, %s) on host ‘%s’ due to missing keyring: %s",
ref->collection_id, refs[i]->ref_name, service->address,
@@ -788,10 +790,11 @@ ostree_avahi_service_build_repo_finder_result (OstreeAvahiService
/* Add this repo to the results, keyed by the canonicalised repository URI
* to deduplicate the results. */
- g_debug ("Resolved ref (%s, %s) to repo URI ‘%s’ with keyring ‘%s’.",
- ref->collection_id, ref->ref_name, uri, keyring);
+ g_debug ("Resolved ref (%s, %s) to repo URI ‘%s’ with keyring ‘%s’ from remote ‘%s’.",
+ ref->collection_id, ref->ref_name, uri, keyring_remote->keyring,
+ keyring_remote->name);
- resolved_repo = uri_and_keyring_new (uri, keyring);
+ resolved_repo = uri_and_keyring_new (uri, keyring_remote);
supported_ref_to_checksum = g_hash_table_lookup (repo_to_refs, resolved_repo);
@@ -821,7 +824,7 @@ ostree_avahi_service_build_repo_finder_result (OstreeAvahiService
remote = ostree_remote_new (name);
g_clear_pointer (&remote->keyring, g_free);
- remote->keyring = g_strdup (repo->keyring);
+ remote->keyring = g_strdup (repo->keyring_remote->keyring);
/* gpg-verify-summary is false since we use the unsigned summary file support. */
g_key_file_set_string (remote->options, remote->group, "url", repo->uri);