Create backup file when writing new xml file?

Thiago Macieira thiago at
Mon Feb 17 14:34:17 UTC 2014

Em seg 17 fev 2014, às 10:42:44, David Faure escreveu:
> On Sunday 16 February 2014 19:52:36 Thiago Macieira wrote:
> > The simplest operation is to write to a temp file, then rename the
> > original
> > to  the backup name, then rename the temp to the original name. However,
> > what happens if the application crashes between renames? You've got a temp
> > and a backup, but no file.
> Isn't that good enough? That's what backups are for. The usual way to use a
> backup is for the user to rename it to the proper name (e.g. remove
> ".backup") and open it with the application, isn't it?

That's not an atomic operation. There's a brief moment when a file with the 
original name does not exist anymore.

> Alternatively, the application can automatically look for the backup file if
> the main file doesn't exist anymore (e.g. when attempting to reopen the
> file via session management or via "recent documents").

That doesn't help with other applications starting at the same time. And I've 
never seen any application look for backup files but not the main. We can't 
modify every application in existence...

Thiago Macieira - thiago (AT) - thiago (AT)
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

More information about the subsurface mailing list