I'm using rsync to update a "semi-live" repository of files, where users may update either the master or the backup repository. I'm using '--update' to make sure that old files do not overwrite newer files.
In the current code, the timestamp is capture and compared at the beginning of the transfer. At this point, a decision is made if the update will be performed. This implementation create a window where a file on the recieving side can be updated, and then overwritten by a file from the backup repository.
Suggested fix will be to add an extra check for the timestamp of the destination file, before renaming the temporary file into the final name.
With this check, the window where newer files can be written will be reduced to few milliseconds - much better then the current window - few seconds - depending on file size, communication gap, etc. The cost for the extra 'stat' is minor (compared with the overall cost of getting the update).
I'll consider this.