added comment on missing version number in bootcd image names
[plcapi.git] / PLC / Methods / GetBootMedium.py
index 8248409..ba432c3 100644 (file)
@@ -273,6 +273,8 @@ class GetBootMedium(Method):
 
         return (pldistro,fcdistro,arch)
 
+    # xxx Thierry : 5.2.1 build/version.txt for some reason is empty, that's why 
+    # the weird name with downloaded image filenames
     def bootcd_version (self):
         try:
             return file(self.BOOTCDDIR + "/build/version.txt").readline().strip()
@@ -312,8 +314,16 @@ class GetBootMedium(Method):
                     raise PLCInvalidArgument, "File %s not under %s"%(filename,self.WORKDIR)
 
             ### output should not exist (concurrent runs ..)
+            # numerous reports of issues with this policy
+            # looks like people sometime suspend/cancel their download
+            # and this leads to the old file sitting in there forever
+            # so, if the file is older than 5 minutes, we just trash
+            grace=5
+            if os.path.exists(filename) and (time.time()-os.path.getmtime(filename)) >= (grace*60):
+                os.unlink(filename)
             if os.path.exists(filename):
-                raise PLCInvalidArgument, "Resulting file %s already exists"%filename
+                raise PLCInvalidArgument, "Resulting file %s already exists - please try again in %d minutes"%\
+                    (filename,grace)
 
             ### we can now safely create the file,
             ### either we are admin or under a controlled location