Create backup file when writing new xml file?

Thiago Macieira thiago at macieira.org
Thu Feb 20 08:26:30 UTC 2014


Em qui 20 fev 2014, às 11:48:31, David Faure escreveu:
> > It might mean the difference between a "File has changed, Reload?" dialog
> > and a "File was deleted, Close?" one.
> 
> OK, that's a good point.
> 
> Now for a stupid-but-simple suggestion, then:
> * copy (not rename) main file to backup
> * save to temp file
> * atomically rename-overwrite temp file to main file
> 
> This way, the main file always exists.

Yeah, it sounds like the best solution still. Since copying is expensive, we 
can't do it behind the scenes in QSaveFile, so this limits the API.

At best, we can offer a "tryLinkBackup" or something, which might return false 
and tell the user of the API, "sorry, hardlinking didn't work, you need to 
copy", which in turn allows the application to show a progress bar or set a 
busy mouse icon. This API is quite clearly not atomic.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   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