Runtime: create .md5 file at the end of all transfered files being written to disk, so that it presence indicates completeness of transfer.
authorEdouard Tisserant
Tue, 02 Jun 2020 13:37:34 +0200
changeset 2653 8b612b357679
parent 2652 269149e78302
child 2678 45f1ff6a7f87
Runtime: create .md5 file at the end of all transfered files being written to disk, so that it presence indicates completeness of transfer.
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: