[recipes] exporter: Use a better filename
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] exporter: Use a better filename
- Date: Sat, 11 Mar 2017 22:51:06 +0000 (UTC)
commit cbba4a39a1202b06c9fcb5a9e05c098d5c4ef78c
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Mar 11 17:50:05 2017 -0500
exporter: Use a better filename
Generate the filename based on the name of the first
recipe. This should produce better results in most
cases.
https://bugzilla.gnome.org/show_bug.cgi?id=779919
src/gr-recipe-exporter.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/src/gr-recipe-exporter.c b/src/gr-recipe-exporter.c
index 050b6a5..f676ec7 100644
--- a/src/gr-recipe-exporter.c
+++ b/src/gr-recipe-exporter.c
@@ -522,10 +522,24 @@ do_export (GrRecipeExporter *exporter)
{
int i;
g_autofree char *path = NULL;
+ int extra;
+ g_autofree char *name = NULL;
+
+ extra = g_list_length (exporter->recipes);
+ if (extra > 1)
+ name = g_strdup_printf ("%s (%d recipes)", gr_recipe_get_name (GR_RECIPE
(exporter->recipes->data)), extra);
+ else
+ name = g_strdup (gr_recipe_get_name (GR_RECIPE (exporter->recipes->data)));
+ g_strdelimit (name, "./", ' ');
for (i = 0; i < 1000; i++) {
g_autofree char *tmp;
- tmp = g_strdup_printf ("%s/recipes%d.gnome-recipes-export", get_user_data_dir (), i);
+
+ if (i == 0)
+ tmp = g_strdup_printf ("%s/%s.gnome-recipes-export", get_user_data_dir (), name);
+ else
+ tmp = g_strdup_printf ("%s/%s(%d).gnome-recipes-export", get_user_data_dir (), name,
i);
+
if (!g_file_test (tmp, G_FILE_TEST_EXISTS)) {
path = g_strdup (tmp);
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]