summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2015-03-25 18:03:16 +0000
committerRichard Hughes <richard@hughsie.com>2015-03-25 18:03:18 +0000
commit5f214d14c9d7d13da2f561c1a4199f2bf7517895 (patch)
treea3424f72bf050f331f79e2ea494d1cd9180f557f
parent775b4ea4a1848bffd10c0818e6af403977b0d150 (diff)
downloadappstream-glib-5f214d14c9d7d13da2f561c1a4199f2bf7517895.tar.gz
Put all the screenshots in a file rather than just writing to the upload path
This is the first step to decouple the mirroring of the screenshots from the appstream metadata generation.
-rw-r--r--client/as-builder.c2
-rw-r--r--libappstream-builder/asb-context.c30
-rw-r--r--libappstream-builder/asb-self-test.c2
3 files changed, 33 insertions, 1 deletions
diff --git a/client/as-builder.c b/client/as-builder.c
index d706b4a..d7894ab 100644
--- a/client/as-builder.c
+++ b/client/as-builder.c
@@ -280,7 +280,7 @@ main (int argc, char **argv)
if (log_dir == NULL)
log_dir = g_strdup ("./logs");
if (screenshot_dir == NULL)
- screenshot_dir = g_strdup ("./screenshots");
+ screenshot_dir = g_build_filename (temp_dir, "screenshots", NULL);
if (output_dir == NULL)
output_dir = g_strdup (".");
if (icons_dir == NULL)
diff --git a/libappstream-builder/asb-context.c b/libappstream-builder/asb-context.c
index 38945e5..38ee196 100644
--- a/libappstream-builder/asb-context.c
+++ b/libappstream-builder/asb-context.c
@@ -914,6 +914,29 @@ asb_context_write_icons (AsbContext *ctx,
}
/**
+ * asb_context_write_screenshots:
+ **/
+static gboolean
+asb_context_write_screenshots (AsbContext *ctx,
+ const gchar *temp_dir,
+ GError **error)
+{
+ AsbContextPrivate *priv = GET_PRIVATE (ctx);
+ _cleanup_free_ gchar *filename = NULL;
+
+ /* not enabled */
+ if (priv->flags & ASB_CONTEXT_FLAG_UNCOMPRESSED_ICONS)
+ return TRUE;
+
+ if (!g_file_test (priv->screenshot_dir, G_FILE_TEST_EXISTS))
+ return TRUE;
+ filename = g_strdup_printf ("%s/%s-screenshots.tar",
+ priv->output_dir, priv->basename);
+ g_print ("Writing %s...\n", filename);
+ return asb_utils_write_archive_dir (filename, priv->screenshot_dir, error);
+}
+
+/**
* asb_context_write_xml:
**/
static gboolean
@@ -1466,6 +1489,13 @@ asb_context_process (AsbContext *ctx, GError **error)
if (!ret)
return FALSE;
+ /* write screenshots archive */
+ ret = asb_context_write_screenshots (ctx,
+ priv->temp_dir,
+ error);
+ if (!ret)
+ return FALSE;
+
/* ensure all packages are flushed */
for (i = 0; i < priv->packages->len; i++) {
pkg = g_ptr_array_index (priv->packages, i);
diff --git a/libappstream-builder/asb-self-test.c b/libappstream-builder/asb-self-test.c
index 5eca682..946c2f1 100644
--- a/libappstream-builder/asb-self-test.c
+++ b/libappstream-builder/asb-self-test.c
@@ -341,6 +341,7 @@ asb_test_context_test_func (AsbTestContextMode mode)
asb_context_set_output_dir (ctx, "/tmp/asbuilder/output");
asb_context_set_temp_dir (ctx, "/tmp/asbuilder/temp");
asb_context_set_icons_dir (ctx, "/tmp/asbuilder/temp/icons");
+ asb_context_set_screenshot_dir (ctx, "/tmp/asbuilder/temp/screenshots");
switch (mode) {
case ASB_TEST_CONTEXT_MODE_WITH_CACHE:
asb_context_set_old_metadata (ctx, "/tmp/asbuilder/output");
@@ -395,6 +396,7 @@ asb_test_context_test_func (AsbTestContextMode mode)
g_assert (g_file_test ("/tmp/asbuilder/output/appstream-failed.xml.gz", G_FILE_TEST_EXISTS));
g_assert (g_file_test ("/tmp/asbuilder/output/appstream-ignore.xml.gz", G_FILE_TEST_EXISTS));
g_assert (g_file_test ("/tmp/asbuilder/output/appstream-icons.tar.gz", G_FILE_TEST_EXISTS));
+ g_assert (g_file_test ("/tmp/asbuilder/output/appstream-screenshots.tar", G_FILE_TEST_EXISTS));
/* load AppStream metadata */
file = g_file_new_for_path ("/tmp/asbuilder/output/appstream.xml.gz");