From 6cfcf55f4ca025d4977cb40eb9a069bb7331032e Mon Sep 17 00:00:00 2001 From: Fabrice Le Goff <fabrice.le.goff@cern.ch> Date: Mon, 13 Aug 2018 09:02:08 +0200 Subject: [PATCH] log critical instead of crashing on externally-removed file --- Script/CopyThread.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Script/CopyThread.py b/Script/CopyThread.py index f72928a..8293cce 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 -- GitLab