From ddf872a5d5b6eddaf92513a2cac6c31c0b8cc801 Mon Sep 17 00:00:00 2001 From: Fabrice Le Goff <fabrice.le.goff@cern.ch> Date: Wed, 22 Aug 2018 17:29:13 +0200 Subject: [PATCH] do not check file size if MinSizekB is not set --- Script/ManagerThread.py | 42 ++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/Script/ManagerThread.py b/Script/ManagerThread.py index 96a2953..a31996e 100644 --- a/Script/ManagerThread.py +++ b/Script/ManagerThread.py @@ -240,28 +240,28 @@ class ManagerThread(threading.Thread): # end if ### Check for minimal file size, if needed - try: - filesize = os.path.getsize(filename) - 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 file size for %s: not present (deleted by external cause)', filename) - continue - else: - raise exc - - if self.MinSizekB and \ - filesize/1024.< self.MinSizekB: - self.logger.debug('File %s is too small. Skipping.', filename) - if self.RemoveSmallFiles: - self.logger.debug('File %s is too small. Deleting.', filename) - try: - os.remove(filename) - except OSError, ex: - self.logger.warning('Cannot delete %s. ERROR: %s', filename, ex.__repr__()) + if self.MinSizekB: + try: + filesize = os.path.getsize(filename) + 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 file size for %s: no such file', filename) + continue + else: + raise exc + + if filesize/1024.< self.MinSizekB: + self.logger.debug('File %s is too small. Skipping.', filename) + if self.RemoveSmallFiles: + self.logger.debug('File %s is too small. Deleting.', filename) + try: + os.remove(filename) + except OSError, ex: + self.logger.warning('Cannot delete %s. ERROR: %s', filename, ex.__repr__()) - continue + continue ##### Do not take already listed files ##### -- GitLab