[recipes] Improve file naming for exports



commit ee5ffaa112819f6d4e13606a85ab1c321af4e404
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Jan 2 14:34:43 2017 -0500

    Improve file naming for exports
    
    Create an archive that is named after the recipe.

 src/gr-details-page.c    |   11 ++++++++++-
 src/gr-recipe-exporter.c |    1 +
 2 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/src/gr-details-page.c b/src/gr-details-page.c
index d906f35..26c6aac 100644
--- a/src/gr-details-page.c
+++ b/src/gr-details-page.c
@@ -289,6 +289,9 @@ print_recipe (GrDetailsPage *page)
 static void
 export_recipe (GrDetailsPage *page)
 {
+        g_autofree char *dir = NULL;
+        g_autofree char *basename = NULL;
+        g_autofree char *path = NULL;
         g_autoptr(GFile) file = NULL;
 
         if (!page->exporter) {
@@ -298,7 +301,13 @@ export_recipe (GrDetailsPage *page)
                 page->exporter = gr_recipe_exporter_new (GTK_WINDOW (window));
         }
 
-        file = g_file_new_for_path (g_get_tmp_dir ());
+        dir = g_dir_make_tmp ("recipesXXXXXX", NULL);
+        basename = g_strconcat (gr_recipe_get_name (page->recipe), ".tar.gz", NULL);
+        if (dir)
+                path = g_build_filename (dir, basename, NULL);
+        else
+                path = g_strdup (basename);
+        file = g_file_new_for_path (path);
         gr_recipe_exporter_export_to (page->exporter, page->recipe, file);
 }
 
diff --git a/src/gr-recipe-exporter.c b/src/gr-recipe-exporter.c
index 852dc78..180740c 100644
--- a/src/gr-recipe-exporter.c
+++ b/src/gr-recipe-exporter.c
@@ -360,6 +360,7 @@ gr_recipe_exporter_export_to (GrRecipeExporter *exporter,
 #ifdef ENABLE_AUTOAR
         exporter->compressor = autoar_compressor_new (exporter->sources, exporter->output, 
AUTOAR_FORMAT_TAR, AUTOAR_FILTER_GZIP, FALSE);
 
+        autoar_compressor_set_output_is_dest (exporter->compressor, TRUE);
         g_signal_connect (exporter->compressor, "decide-dest", G_CALLBACK (decide_dest_cb), exporter);
         g_signal_connect (exporter->compressor, "completed", G_CALLBACK (completed_cb), exporter);
         g_signal_connect (exporter->compressor, "error", G_CALLBACK (error_cb), exporter);


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