diff --git a/transfer_service/file_cleaner.py b/transfer_service/file_cleaner.py index 73d842d95d043f367bbfdb3273954372b9eea0ba..533c4343a58b689d0c32064ca3b0d7c46f1bfc5e 100644 --- a/transfer_service/file_cleaner.py +++ b/transfer_service/file_cleaner.py @@ -74,14 +74,15 @@ class FileCleaner(object): nodeId = row["node_id"] delta = cTime - dTime if delta.days >= self.days and delta.seconds > self.seconds: - os.remove(filePath) - self.logger.debug(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ' ' + filePath) + if os.path.exists(filePath): + os.remove(filePath) + self.logger.debug(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ' ' + filePath) try: self.dbConn.setPhyDeletedOn(nodeId) except Exception: self.logger.exception(f"FATAL: unable to set the 'phy_deleted_on' flag for VOSpace node having ID = {nodeId}") return - if basePath not in basePaths: + if os.path.exists(basePath) and basePath not in basePaths: basePaths.append(basePath) self.logger.info("Removing empty folders (if any)...") for basePath in basePaths: