Fix PLCObject's purge failing silently with extra_files.
authorEdouard Tisserant
Thu, 06 Jun 2019 14:03:16 +0200
changeset 2613 e05458405ff4
parent 2612 98eb3d1c56b0
child 2614 6b4061f6ced6
Fix PLCObject's purge failing silently with extra_files.
runtime/PLCObject.py
--- a/runtime/PLCObject.py	Thu May 30 11:53:13 2019 +0200
+++ b/runtime/PLCObject.py	Thu Jun 06 14:03:16 2019 +0200
@@ -560,18 +560,20 @@
             if self.CurrentPLCFilename is not None \
             else None
 
-        allfiles = [extra_files_log, old_PLC_filename, self._GetMD5FileName()]
-
         try:
-            allfiles.append(open(extra_files_log, "rt").readlines())
+            allfiles = open(extra_files_log, "rt").readlines()
+            allfiles.extend([extra_files_log, old_PLC_filename, self._GetMD5FileName()])
         except Exception:
-            pass
+            self.LogMessage("No files to purge")
+            allfiles = []
 
         for filename in allfiles:
-            try:
-                os.remove(os.path.join(self.workingdir, filename.strip()))
-            except Exception:
-                pass
+            if filename:
+                filename = filename.strip()
+                try:
+                    os.remove(os.path.join(self.workingdir, filename))
+                except Exception:
+                    self.LogMessage("Couldn't purge " + filename)
 
         self.PLCStatus = PlcStatus.Empty