And this time with the attachment :-S

Cheers
Lex

On 19 November 2010 08:20, Lex Trotman <ele...@gmail.com> wrote:
> On 19 November 2010 06:04, Nick Treleaven <nick.trelea...@btinternet.com> 
> wrote:
>> On Mon, 15 Nov 2010 08:57:51 +1100
>> Lex Trotman <ele...@gmail.com> wrote:
>>
>>> >> > Also, g_file_replace_contents does have a make_backup argument we could
>>> >> > provide an option for. This might handle the disk exhaustion problem.
>>> >>
>>> >> To summarise the long thread for you Nick, g_file_replace_contents and
>>> >> g_file_replace can't be used because there is NO WAY to stop
>>> >> g_stream_close doing the rename of the temp file over the old file
>>> >> even if the write to the temp file fails.  So you can get a broken
>>> >> output file.
>>> >
>>> > I know. But at the least the user has the backup file then.
>>>
>>> Attached is a patch to actually make the backup :-)
>>
>> Ok. We do have some backup functionality in the Save Actions plugin,
>> but anyway this pref may be more efficient.
>
> Yes, save actions is fine on a local disk and much more flexible since
> you can choose name and location for backups, but it copies the file
> which is a performance problem for remote filesystems which was one of
> the initiating complaints on the long "safe file save" thread IIRC.
>
>>
>> I think either:
>> 1. unsafe_save_backup should be renamed to gio_unsafe_save_backup to
>> avoid confusion.
>
> Ok, attached.
>
>> 2. call the pref make_backup and make it work for all save
>> implementations, and maybe have a GUI option for it.
>
> To do this we would almost be writing the whole of GIO with the
> algorithm I outlined previously.  So we probably should do that
> instead.  For now lets just offer this easy option that provides
> improved performance on remote filesystems.
>
> Cheers
> Lex
>
>>
>> Nick
>> _______________________________________________
>> Geany-devel mailing list
>> Geany-devel@uvena.de
>> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
>>
>
Index: keyfile.c
===================================================================
--- keyfile.c	(revision 5410)
+++ keyfile.c	(working copy)
@@ -189,6 +189,8 @@
 		"complete_snippets_whilst_editing", FALSE);
 	stash_group_add_boolean(group, &file_prefs.use_safe_file_saving,
 		"use_safe_file_saving", FALSE);
+	stash_group_add_boolean(group, &file_prefs.gio_unsafe_save_backup,
+		"gio_unsafe_save_backup", FALSE);
 	/* for backwards-compatibility */
 	stash_group_add_integer(group, &editor_prefs.indentation->hard_tab_width,
 		"indent_hard_tab_width", 8);
Index: document.c
===================================================================
--- document.c	(revision 5410)
+++ document.c	(working copy)
@@ -1721,7 +1721,7 @@
 
 		/* 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_replace_contents(fp, data, len, NULL, file_prefs.gio_unsafe_save_backup,
 			G_FILE_CREATE_NONE, NULL, NULL, &error);
 		g_object_unref(fp);
 #else
Index: document.h
===================================================================
--- document.h	(revision 5410)
+++ document.h	(working copy)
@@ -59,6 +59,7 @@
 	gint			disk_check_timeout;
 	gboolean		cmdline_new_files;	/* New file if command-line filename doesn't exist */
 	gboolean		use_safe_file_saving;
+	gboolean		gio_unsafe_save_backup;
 	gboolean		ensure_convert_new_lines;
 }
 GeanyFilePrefs;
Index: ../doc/geany.txt
===================================================================
--- ../doc/geany.txt	(revision 5410)
+++ ../doc/geany.txt	(working copy)
@@ -4211,6 +4211,8 @@
                                   break things seriously.
                                   The better approach would be to ensure your
                                   disk won't run out of free space.
+gio_unsafe_save_backup            Make a backup when using GIO unsafe file     false
+                                  saving.  Backup is named filename~.
 **Search related**
 find_selection_type               See `Find selection`_.                       0
 **Build Menu related**
_______________________________________________
Geany-devel mailing list
Geany-devel@uvena.de
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel

Reply via email to