[krita/video-export-rebased] libs/ui: Save to a temporary file, then copy the result over on success (fwd)

Boudewijn Rempt boud at valdyas.org
Tue Aug 16 16:15:22 UTC 2016


On Tue, 16 Aug 2016, Fazekas László wrote:

> Maybe this way?
> 
> 1. copy the original file into original.bak in the same folder
> 
> - if the disk space is not enough, then drop the .bak file

That is already done, but that's something people can disable. Apparently,
when this system was designed twenty years ago, the backup files were only
meant to give people a chance to go to a previous version.

> 
> 2. write the new contents into the original file
> 
> -in case of a full disk error, delete the .bak file and try to continue
> 

That would be very dangerous. The original should always be available if
saving fails.

> -if any other error happens, you can stop with an error (it's safer to leave
> the files)
> 
> 3. if everything finished well, delete the .bak file (or optionally keep it)
> 
> This way you never delete or rename the original file.
> 
> For network files, I think it's not safe if you create the file locally in
> tmp, then save it over the original. This can damage the original, since
> networking is also not safe.

That's why the original is renamed before copying the new version over. Renaming
over a network should be safe.

> 
> Fazek
> 
> 2016-08-16 17:32 keltezéssel, Dmitry Kazakov írta:
> > Can we somehow limit this behavior to network files only?
> > 
> > 
> > There are two problems I see:
> > 
> > 1) If some other application, like Blender, is waiting on Krita-edited file
> > with inotify (QFileSystemWatcher), it may go crazy when we rename and
> > delete the file. The inotify opject will be destroyed after that.
> > 2) What if the user works with 700MiB image? It mean he needs twice the
> > size of the image free space just to be able to save it. Many people will
> > be unhappy with it.
> > 3) What if there is not enough free space in Temp folder? The user will
> > never be able to save the image? That is a dataloss bug.
> > 
> > 
> > ---
> > Dmitry Kazakov
> > 
> 
> 

-- 
Boudewijn Rempt | http://www.krita.org, http://www.valdyas.org


More information about the kimageshop mailing list