From fe47e35691dc5f570077596288b59d967970efe1 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Tue, 12 Aug 2014 10:52:03 +0100 Subject: Do not try to download screenshots when run with --nonet --- libappstream-builder/asb-context.c | 17 +++++++++++++++++ libappstream-builder/asb-context.h | 1 + libappstream-builder/plugins/asb-plugin-appdata.c | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/libappstream-builder/asb-context.c b/libappstream-builder/asb-context.c index 8ad265e..8d073cd 100644 --- a/libappstream-builder/asb-context.c +++ b/libappstream-builder/asb-context.c @@ -362,6 +362,23 @@ asb_context_get_add_cache_id (AsbContext *ctx) return priv->add_cache_id; } +/** + * asb_context_get_no_net: + * @ctx: A #AsbContext + * + * Gets if network access is forbidden. + * + * Returns: boolean + * + * Since: 0.2.5 + **/ +gboolean +asb_context_get_no_net (AsbContext *ctx) +{ + AsbContextPrivate *priv = GET_PRIVATE (ctx); + return priv->no_net; +} + /** * asb_context_get_api_version: * @ctx: A #AsbContext diff --git a/libappstream-builder/asb-context.h b/libappstream-builder/asb-context.h index d01f129..817ef8e 100644 --- a/libappstream-builder/asb-context.h +++ b/libappstream-builder/asb-context.h @@ -88,6 +88,7 @@ void asb_context_set_basename (AsbContext *ctx, const gchar *basename); const gchar *asb_context_get_temp_dir (AsbContext *ctx); gboolean asb_context_get_add_cache_id (AsbContext *ctx); +gboolean asb_context_get_no_net (AsbContext *ctx); gdouble asb_context_get_api_version (AsbContext *ctx); gboolean asb_context_setup (AsbContext *ctx, diff --git a/libappstream-builder/plugins/asb-plugin-appdata.c b/libappstream-builder/plugins/asb-plugin-appdata.c index eb5fb88..555a7c1 100644 --- a/libappstream-builder/plugins/asb-plugin-appdata.c +++ b/libappstream-builder/plugins/asb-plugin-appdata.c @@ -199,6 +199,12 @@ asb_plugin_appdata_load_url (AsbPlugin *plugin, as_app_get_id (AS_APP (app)), basename); if (!g_file_test (cache_filename, G_FILE_TEST_EXISTS)) { + if (asb_context_get_no_net (plugin->ctx)) { + asb_package_log (asb_app_get_package (app), + ASB_PACKAGE_LOG_LEVEL_WARNING, + "Could not download %s as no network", url); + goto out; + } uri = soup_uri_new (url); if (uri == NULL) { ret = FALSE; -- cgit v1.2.1