summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Untz <vuntz@gnome.org>2007-09-01 14:29:28 +0000
committerVincent Untz <vuntz@gnome.org>2007-09-01 14:29:28 +0000
commite08e4ea54ab1c90475f4a52bee98e234e7c79d1a (patch)
tree9c1d5da727509635d615e6a272f0e28a496caab4
parentc7d783c84eec8d07049ab01988e4da43559ce80f (diff)
validate the desktop file after modifying its content, but before doing
2007-09-01 Vincent Untz <vuntz@gnome.org> * src/install.c: (process_one_file): validate the desktop file after modifying its content, but before doing anything else, so that we don't unlink the original file if the created one is not valid. Also, unlink the created file if it's not valid.
-rw-r--r--ChangeLog7
-rw-r--r--src/install.c19
2 files changed, 17 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index fa3fb65..2a83db5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2007-09-01 Vincent Untz <vuntz@gnome.org>
+ * src/install.c: (process_one_file): validate the desktop file after
+ modifying its content, but before doing anything else, so that we
+ don't unlink the original file if the created one is not valid.
+ Also, unlink the created file if it's not valid.
+
+2007-09-01 Vincent Untz <vuntz@gnome.org>
+
Don't exit(), but let the main() function do it with a proper error
message.
diff --git a/src/install.c b/src/install.c
index dc93836..b21b337 100644
--- a/src/install.c
+++ b/src/install.c
@@ -191,6 +191,16 @@ process_one_file (const char *filename,
g_key_file_free (kf);
+ /* Load and validate the file we just wrote */
+ if (!desktop_file_validate (new_filename, FALSE, TRUE))
+ {
+ g_set_error (err, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_PARSE,
+ _("Failed to validate the created desktop file"));
+ g_unlink (new_filename);
+ g_free (new_filename);
+ return;
+ }
+
if (g_chmod (new_filename, permissions) < 0)
{
g_set_error (err, G_FILE_ERROR,
@@ -211,15 +221,6 @@ process_one_file (const char *filename,
filename, g_strerror (errno));
}
- /* Load and validate the file we just wrote */
- if (!desktop_file_validate (new_filename, FALSE, TRUE))
- {
- g_free (new_filename);
- g_set_error (err, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_PARSE,
- _("Failed to validate the created desktop file"));
- return;
- }
-
if (rebuild_mime_info_cache)
{
rebuild_error = NULL;