summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2014-08-12 10:52:03 +0100
committerRichard Hughes <richard@hughsie.com>2014-08-12 12:24:46 +0100
commitfe47e35691dc5f570077596288b59d967970efe1 (patch)
tree7a27fa0f4a1c8f2f811738029cfb7eea0b74fe8b
parente0ef6ffeff3bd473669edbbd50ec383a483a23f4 (diff)
downloadappstream-glib-fe47e35691dc5f570077596288b59d967970efe1.tar.gz
Do not try to download screenshots when run with --nonet
-rw-r--r--libappstream-builder/asb-context.c17
-rw-r--r--libappstream-builder/asb-context.h1
-rw-r--r--libappstream-builder/plugins/asb-plugin-appdata.c6
3 files changed, 24 insertions, 0 deletions
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
@@ -363,6 +363,23 @@ asb_context_get_add_cache_id (AsbContext *ctx)
}
/**
+ * 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;