SF.net SVN: geany:[5370] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Sun Nov 7 13:08:13 UTC 2010


Revision: 5370
          http://geany.svn.sourceforge.net/geany/?rev=5370&view=rev
Author:   ntrel
Date:     2010-11-07 13:08:13 +0000 (Sun, 07 Nov 2010)

Log Message:
-----------
Make use_safe_file_saving hidden pref apply even when GIO is
available, because g_file_replace_contents() doesn't handle disk
space exhaustion.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/document.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2010-11-05 22:22:12 UTC (rev 5369)
+++ trunk/ChangeLog	2010-11-07 13:08:13 UTC (rev 5370)
@@ -1,3 +1,11 @@
+2010-11-07  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
+
+ * src/document.c:
+   Make use_safe_file_saving hidden pref apply even when GIO is
+   available, because g_file_replace_contents() doesn't handle disk
+   space exhaustion.
+
+
 2010-11-04  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
 
  * src/filetypes.c:

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2010-11-05 22:22:12 UTC (rev 5369)
+++ trunk/src/document.c	2010-11-07 13:08:13 UTC (rev 5370)
@@ -1712,21 +1712,22 @@
 								 const gchar *data, gint len)
 {
 	GError *error = NULL;
+
+	if (! file_prefs.use_safe_file_saving)
+	{
 #ifdef HAVE_GIO
-	GFile *fp;
+		GFile *fp;
 
-	/* Use GIO API to save file (GVFS-safe) */
-	fp = g_file_new_for_path(locale_filename);
-	g_file_replace_contents(fp, data, len, NULL, FALSE,
-		G_FILE_CREATE_NONE, NULL, NULL, &error);
-	g_object_unref(fp);
+		/* Use GIO API to save file (GVFS-safe) */
+		fp = g_file_new_for_path(locale_filename);
+		g_file_replace_contents(fp, data, len, NULL, FALSE,
+			G_FILE_CREATE_NONE, NULL, NULL, &error);
+		g_object_unref(fp);
 #else
-	gint err = 0;
-	FILE *fp;
-	gint bytes_written;
+		gint err = 0;
+		FILE *fp;
+		gint bytes_written;
 
-	if (! file_prefs.use_safe_file_saving)
-	{
 		/* Use POSIX API for unsafe saving (GVFS-unsafe) */
 		fp = g_fopen(locale_filename, "wb");
 		if (G_UNLIKELY(fp == NULL))
@@ -1741,13 +1742,14 @@
 
 		if (err != 0)
 			return g_strdup(g_strerror(err));
+#endif
 	}
 	else
 	{
-		/* Use old GLib API for safe saving (GVFS-safe, but alters ownership and permissons) */
+		/* Use old GLib API for safe saving (GVFS-safe, but alters ownership and permissons).
+		 * This is the only option that handles disk space exhaustion. */
 		g_file_set_contents(locale_filename, data, len, &error);
 	}
-#endif
 	if (error != NULL)
 	{
 		gchar *msg = g_strdup(error->message);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list