diff --git a/Script/CopyThread.py b/Script/CopyThread.py index f72928a4ef460e3c203fecd4576db428691d257b..8293cce3bca7ce3de6ab86339036389116f0ef08 100644 --- a/Script/CopyThread.py +++ b/Script/CopyThread.py @@ -134,7 +134,22 @@ class CopyThread(threading.Thread): #### Fetch information for consistency checks - local_filesize = os.stat(copyfile[0])[6] + try: + local_filesize = os.stat(copyfile[0])[6] + except OSError as exc: + if exc.errno == errno.ENOENT: + # The file has been removed by an external cause. + # This is bad but this is not a reason to crash. + self.logger.critical('error getting local file size %s: not present (deleted by external cause)', copyfile[0] + Constants.tobecopied_ext) + # delete associated file (ignoring errors) + try: + os.remove(copyfile[0] + Constants.tobecopied_ext) + except: + pass + self.ClearQueue.put(copyfile) + continue + else: + raise exc dbchecksum = dbfilesize = filehealth = None