[gnome-software/mwleeds/minor-offline-fixes: 1/2] flatpak: Properly detect offline case
- From: Phaedrus Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/mwleeds/minor-offline-fixes: 1/2] flatpak: Properly detect offline case
- Date: Wed, 10 Feb 2021 19:24:19 +0000 (UTC)
commit 0fbeaddc82952368460bfabeeb10f1e869d83f8b
Author: Phaedrus Leeds <mwleeds endlessos org>
Date: Mon Feb 8 17:58:32 2021 -0800
flatpak: Properly detect offline case
We want to still refine what information we can if we fail to get size
information due to being offline. There was already a check to that
effect but the code path wasn't being hit because the
GS_PLUGIN_ERROR_NO_NETWORK error code wasn't being set.
plugins/flatpak/gs-flatpak.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index dd7f3ee20..830b824bf 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -2124,6 +2124,7 @@ gs_flatpak_fetch_remote_metadata (GsFlatpak *self,
{
g_autoptr(GBytes) data = NULL;
g_autoptr(FlatpakRef) xref = NULL;
+ g_autoptr(GError) local_error = NULL;
/* no origin */
if (gs_app_get_origin (app) == NULL) {
@@ -2143,9 +2144,20 @@ gs_flatpak_fetch_remote_metadata (GsFlatpak *self,
gs_app_get_origin (app),
xref,
cancellable,
- error);
+ &local_error);
if (data == NULL) {
- gs_flatpak_error_convert (error);
+#if FLATPAK_CHECK_VERSION(1,4,0)
+ if (g_error_matches (local_error, FLATPAK_ERROR, FLATPAK_ERROR_REF_NOT_FOUND) &&
+#else
+ if (g_error_matches (local_error, FLATPAK_ERROR, FLATPAK_ERROR_INVALID_DATA) &&
+#endif
+ !gs_plugin_get_network_available (self->plugin)) {
+ local_error->code = GS_PLUGIN_ERROR_NO_NETWORK;
+ local_error->domain = GS_PLUGIN_ERROR;
+ } else {
+ gs_flatpak_error_convert (&local_error);
+ }
+ g_propagate_error (error, g_steal_pointer (&local_error));
return NULL;
}
return g_steal_pointer (&data);
@@ -2695,8 +2707,7 @@ gs_flatpak_refine_app_unlocked (GsFlatpak *self,
g_autoptr(GError) error_local = NULL;
if (!gs_plugin_refine_item_size (self, app,
cancellable, &error_local)) {
- if (!gs_plugin_get_network_available (self->plugin) &&
- g_error_matches (error_local, GS_PLUGIN_ERROR,
+ if (g_error_matches (error_local, GS_PLUGIN_ERROR,
GS_PLUGIN_ERROR_NO_NETWORK)) {
g_debug ("failed to get size while "
"refining app %s: %s",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]