[gnome-builder] flatpak: do network query immediately



commit 38fe8e11a44801bf91ad87878b0e474a7348d4bf
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jan 10 13:24:18 2018 -0800

    flatpak: do network query immediately
    
    We can ignore the rest of the work if the network is down and
    we won't be able to query the peer anyway. It also ensures we
    don't clear the force-update bit.

 src/plugins/flatpak/gbp-flatpak-download-stage.c |   23 ++++++++++-----------
 1 files changed, 11 insertions(+), 12 deletions(-)
---
diff --git a/src/plugins/flatpak/gbp-flatpak-download-stage.c 
b/src/plugins/flatpak/gbp-flatpak-download-stage.c
index b4eeeb4..430321d 100644
--- a/src/plugins/flatpak/gbp-flatpak-download-stage.c
+++ b/src/plugins/flatpak/gbp-flatpak-download-stage.c
@@ -51,7 +51,6 @@ gbp_flatpak_download_stage_query (IdeBuildStage    *stage,
 {
   GbpFlatpakDownloadStage *self = (GbpFlatpakDownloadStage *)stage;
   IdeConfiguration *config;
-  GNetworkMonitor *monitor;
   g_autofree gchar *staging_dir = NULL;
   g_autofree gchar *manifest_path = NULL;
   g_autofree gchar *stop_at_option = NULL;
@@ -62,6 +61,17 @@ gbp_flatpak_download_stage_query (IdeBuildStage    *stage,
   g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
   g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
 
+  /* Ignore downloads if there is no connection */
+  if (!g_network_monitor_get_network_available (g_network_monitor_get_default ()))
+    {
+      ide_build_stage_log (stage,
+                           IDE_BUILD_LOG_STDOUT,
+                           _("Network is not available, skipping downloads"),
+                           -1);
+      ide_build_stage_set_completed (stage, TRUE);
+      return;
+    }
+
   config = ide_build_pipeline_get_configuration (pipeline);
   if (!GBP_IS_FLATPAK_CONFIGURATION (config))
     {
@@ -107,17 +117,6 @@ gbp_flatpak_download_stage_query (IdeBuildStage    *stage,
       self->invalid = FALSE;
       self->force_update = FALSE;
     }
-
-  /* Ignore downloads if there is no connection */
-  monitor = g_network_monitor_get_default ();
-  if (!g_network_monitor_get_network_available (monitor))
-    {
-      ide_build_stage_log (stage,
-                           IDE_BUILD_LOG_STDOUT,
-                           _("Network is not available, skipping downloads"),
-                           -1);
-      ide_build_stage_set_completed (stage, TRUE);
-    }
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]