[Monodevelop-devel] Atomic file write API
Lluis Sanchez Gual
lluis at novell.com
Mon Mar 16 09:10:18 EDT 2009
El dg 15 de 03 de 2009 a les 15:19 -0400, en/na Michael Hutchinson va
> An issue that has recently gained prominence is reliability of file
> writes on Ext4:
> After writing a changed file to disk and the system crashes before the
> changes are flushed from the OS or disk buffers, files can be left in
> a corrupted state.
> The MonoDevelop.Projects TextFile API, in addition to (partially)
> handling file encoding detection, has a file save API that attempts to
> solve this problem by writing the new file contents to a temp file and
> then using a POSIX call to rename the changed file over the old one.
> Unfortunately, I often see code in MD that doesn't use this API.
> Indeed, it's impossible to use it from MonoDevelop.Core, so I had to
> replicate the functionality there some time ago.
> Worse, as described in the posts linked above, this sequence of
> operations isn't guaranteed to be safe on POSIX.
> I think we should add an FileStream-based API to MonoDevelop.Core for
> handling this, with several other features:
> * Levels of reliability: fsync, renaming, unsafe
> * Option to create backup files, with automatic fallbacks to backups
> when loading damaged settings files
> * Autosave to temp files, and prompting the user for recovery of
> autosaved or damaged files after a crash
It sounds ok to me.
More information about the Monodevelop-devel-list