Problem is that have no idea what may cause this, so it would involve improving the debug version iteratively. And as you are not able to reproduce the problem easily it would take ages.
I did notice that the byte count of the file changed on this last time.
Perhaps if some detailed logging was stored in memory all the time and after each file transfer, if the byte count is right, wipe the logging, but if the byte count changes, then write the log file?
Oh, also, this is not strict file transfer, this is double click on file to open in edit mode locally - then use File/Save and have the remote file update.