[Xfce4-commits] <thunar:master> Keep file permissions when renaming a desktop file.

Nick Schermer noreply at xfce.org
Thu Nov 1 21:46:02 CET 2012


Updating branch refs/heads/master
         to 36b4a2778633d3ab8ba51fa951e92c81c3e75254 (commit)
       from 045b964356b60e39fbe90d3ffc21d7abf6707146 (commit)

commit 36b4a2778633d3ab8ba51fa951e92c81c3e75254
Author: Nick Schermer <nick at xfce.org>
Date:   Thu Nov 1 21:25:20 2012 +0100

    Keep file permissions when renaming a desktop file.

 thunar/thunar-gio-extensions.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/thunar/thunar-gio-extensions.c b/thunar/thunar-gio-extensions.c
index 65f3f53..1fd3bef 100644
--- a/thunar/thunar-gio-extensions.c
+++ b/thunar/thunar-gio-extensions.c
@@ -177,8 +177,9 @@ thunar_g_file_write_key_file (GFile        *file,
                               GCancellable *cancellable,
                               GError      **error)
 {
-  gchar *contents;
-  gsize  length;
+  gchar    *contents;
+  gsize     length;
+  gboolean  result = TRUE;
 
   _thunar_return_val_if_fail (G_IS_FILE (file), FALSE);
   _thunar_return_val_if_fail (key_file != NULL, FALSE);
@@ -189,18 +190,17 @@ thunar_g_file_write_key_file (GFile        *file,
   contents = g_key_file_to_data (key_file, &length, NULL);
 
   /* try to replace the file contents with the key file data */
-  if (!g_file_replace_contents (file, contents, length, NULL, FALSE, 
-                                G_FILE_CREATE_REPLACE_DESTINATION,
-                                NULL, cancellable, error))
+  if (contents != NULL)
     {
+      result = g_file_replace_contents (file, contents, length, NULL, FALSE, 
+                                        G_FILE_CREATE_NONE,
+                                        NULL, cancellable, error);
+      
+      /* cleanup */
       g_free (contents);
-      return FALSE;
-    }
-  else
-    {
-      g_free (contents);
-      return TRUE;
     }
+
+  return result;
 }
 
 


More information about the Xfce4-commits mailing list