Runtime: create .md5 file at the end of all transfered files being written to disk, so that it presence indicates completeness of transfer. svghmi
authorEdouard Tisserant
Tue, 02 Jun 2020 13:37:34 +0200
branchsvghmi
changeset 2975 8e8812f13d9d
parent 2974 78938093e8b2
child 2979 9442f6a6449e
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: