[Unison-hackers] Stasher code...

Jerome Vouillon Jerome.Vouillon at pps.jussieu.fr
Mon Jun 8 10:21:24 EDT 2009


Hi,

I'm trying to understand the stasher code, but I'm a bit puzzled.


In files.ml, we have the following piece of code:

    let deleteLocal (fspath, (workingDirOpt, path)) =
    [...]
          Stasher.backup fspath path `AndRemove
    [...]

If "path" contains a followed link, this will backup and delete the
*link*, not the link target as expected.  Stasher.backup should call
Fspath.findWorkingDir to get the right file to rename or delete.


Again in file.ml, we have the following:

  let make_backup =
    (* Perform (asynchronously) a backup of the destination files *)
    Update.updateArchive rootTo pathTo uiTo id

The function Update.updateArchive calls the function
Stasher.stashCurrentVersion, but only after the destination has been
updated (the call is in the archive commit action)...


Still, the destination files are backed-up by the call to
Stasher.backup in Files.renameLocal.


There is also a call to Stasher.stashCurrentVersion in
Update.replaceArchive, which is supposed to perform backups using the
temporary files before they replace the destination files, but perform
backups afterwards.  So it does nothing (this is somewhat coherent
with the implementation of stashCurrentVersion which does not support
recursive traversal of a temporary directory).


Stasher.stashCurrentVersion is also called from transport.ml, on both
replicas, after updates.


As a summary, as far as I can see, Stasher.stashCurrentVersion is
called twice on the source files: once from Update.updateArchive
(called from File.copy) and then once from Transport.doAction.  It is
also called twice on the destination files once modified, from the
same functions.  It is called once on an empty location from
Update.replaceArchive.  Finally, destination files are backed-up
before modification through the call to Stasher.backup in
Files.rename.

If this analysis is correct, I suspect we can safely remove all calls
to Stasher.stashCurrentVersion from file update.ml.

-- Jerome


More information about the Unison-hackers mailing list