# HG changeset patch
# User Edouard Tisserant
# Date 1591097854 -7200
# Node ID 8b612b357679cd074b099c9ab2c59fc99b884206
# Parent  269149e78302ae72930b918e35a277267e22627a
Runtime: create .md5 file at the end of all transfered files being written to disk, so that it presence indicates completeness of transfer.

diff -r 269149e78302 -r 8b612b357679 runtime/PLCObject.py
--- a/runtime/PLCObject.py	Tue Jun 02 11:34:50 2020 +0200
+++ b/runtime/PLCObject.py	Tue Jun 02 13:37:34 2020 +0200
@@ -612,9 +612,6 @@
                 # Create new PLC file
                 self._BlobAsFile(plc_object, new_PLC_filename)
 
-                # Store new PLC filename based on md5 key
-                open(self._GetMD5FileName(), "w").write(md5sum)
-
                 # Then write the files
                 log = open(extra_files_log, "w")
                 for fname, blobID in extrafiles:
@@ -622,6 +619,12 @@
                     self._BlobAsFile(blobID, fpath)
                     log.write(fname+'\n')
 
+                # Store new PLC filename based on md5 key
+                with open(self._GetMD5FileName(), "w") as f:
+                    f.write(md5sum)
+                    f.flush()
+                    os.fsync(f.fileno())
+
                 # Store new PLC filename
                 self.CurrentPLCFilename = NewFileName
             except Exception: