Table of Contents

All you never wanted to know about file saving

Introduction

Geany has a number of options and a plugin controlling the apparently simple operation of saving a buffer to a file. This page gives a more detailed description of the options so that you can make an informed decision which to use, since no one combination is allways “right”.

There is one particular backup of the file saving process that needs to be emphasised first:

The buffer is still available in Geany

No matter what your options settings, if a file save fails you should try to save the buffer to a different device or clear the cause of the failure (disk full, network fault) and try again. You will not lose anything until you close the buffer.

Various Options

The options controlling file saving are all in the “Various” preferences page.

As that page warns “Warning: read the manual before changing these preferences” and you should read this page carefully too.

The three options are:

use_atomic_file_saving

This is off by default.

If neither this option nor use_gio_unsafe_file_saving is set, Geany will use simple overwriting to write the file.

Advantages:

Disadvantages:

If use_atomic_file_saving is set, use_gio_unsafe_file_saving is ignored and Geany will use an atomic file save method. This means that the file is first written to a temporary file, then renamed to the existing file name. On most file systems rename is atomic, that is it succeeds completely or nothing will change, especially on modern journalling systems. This functionality is provided and maintained by the Glib library.

Advantages:

Disadvantages:

use_gio_unsafe_file_saving

This is on by the default, and is provided by the GIO library.

This option attempts to deal with as many of the issues associated with the other methods as it can:

Advantages:

Disadvantages:

gio_unsafe_save_backup

This is off by default.

The GIO library function used for use_gio_unsafe_file_saving above has an option to make a backup copy of the existing file before overwriting it.

The backup file is located in the same directory as the file being written, and is named the same but with a tilde (~) appended.

Advantages:

Disadvantages:

Save Actions plugin

The Save Actions plugin is distributed with Geany and if it is enabled it provides two actions relevant to this discussion (plus others).

Autosave

Any situation that causes Geany to stop unexpectedly can cause unsaved files to be lost, that includes logout, shutdown, crash etc.

If enabled, the Autosave action saves documents to file periodically. It can be set to save just the current document or all documents, but that may interrupt Geany if many changed documents are saved to a slow filesystem.

Autosave uses the method selected by the options above.

Advantages:

Disadvantages:

Backup Copy

Makes a copy of the file every time after the buffer is saved successfully. If the next save fails, this backup is available.

Unlike gio_unsafe_save_backup this plugin works with all saving methods and can be set to save the backup to a different location from the data file, so a slow remote file may be backed up on a fast local disk.

The backup files are named the same as the file being written with the date/time appended. This means each backup file has a different name and won't overwrite the previous backup.

But the backup cache can fill up (especially if autosave is on) and needs to be manually cleaned up regularly.

Advantages:

Disadvantages: