From d9ec8598789b39152bd78b7cd16044ccea26aea0 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Wed, 1 Jun 2016 05:58:21 +0000 Subject: [PATCH 1/3] summary: Don't cache summary if none was returned ostree_repo_remote_fetch_summary can set out_summary to NULL but still return TRUE according to the documentation, so don't assume that *out_summary will always be set. --- common/flatpak-dir.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c index c7459665..d68e5400 100644 --- a/common/flatpak-dir.c +++ b/common/flatpak-dir.c @@ -3747,6 +3747,10 @@ flatpak_dir_cache_summary (FlatpakDir *self, CachedSummary *summary; GBytes *res = NULL; + /* No sense caching the summary if there isn't one */ + if (!bytes) + return NULL; + G_LOCK (cache); /* This was already initialized in the cache-miss lookup */ From c533e1aee6e92b82625dda50dd042e6122e7d1f0 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Wed, 1 Jun 2016 05:59:54 +0000 Subject: [PATCH 2/3] summary: Make flatpak_cache_dir_summary static void This function always returned NULL, and the return value was never checked. --- common/flatpak-dir.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c index d68e5400..781be2a7 100644 --- a/common/flatpak-dir.c +++ b/common/flatpak-dir.c @@ -3738,18 +3738,17 @@ flatpak_dir_lookup_cached_summary (FlatpakDir *self, return res; } -static GBytes * +static void flatpak_dir_cache_summary (FlatpakDir *self, GBytes *bytes, const char *name, const char *url) { CachedSummary *summary; - GBytes *res = NULL; /* No sense caching the summary if there isn't one */ if (!bytes) - return NULL; + return; G_LOCK (cache); @@ -3760,8 +3759,6 @@ flatpak_dir_cache_summary (FlatpakDir *self, g_hash_table_insert (self->summary_cache, summary->remote, summary); G_UNLOCK (cache); - - return res; } static gboolean From 4fb1ae0b455b794e1b7ec465f0714f59a2572f9e Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Wed, 1 Jun 2016 06:03:47 +0000 Subject: [PATCH 3/3] remote: Make the error message when summary_bytes == NULL more informative It seems like one common user-error that could cause this is when the remote URL was invalid. --- common/flatpak-dir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c index 781be2a7..f2b95752 100644 --- a/common/flatpak-dir.c +++ b/common/flatpak-dir.c @@ -3821,7 +3821,8 @@ flatpak_dir_remote_list_refs (FlatpakDir *self, return FALSE; if (summary_bytes == NULL) - return flatpak_fail (error, "Remote listing not available; server has no summary file\n"); + return flatpak_fail (error, "Remote listing not available; server has no summary file\n" \ + "Check the URL passed to remote-add was valid\n"); ret_all_refs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); summary = g_variant_new_from_bytes (OSTREE_SUMMARY_GVARIANT_FORMAT,