From 704447e1c6d94e2be1caaf56231554951cdb0d0e Mon Sep 17 00:00:00 2001 From: Cristiano Urban Date: Thu, 13 Jan 2022 12:03:04 +0100 Subject: [PATCH] Minor fix. Signed-off-by: Cristiano Urban --- transfer_service/file_cleaner.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/transfer_service/file_cleaner.py b/transfer_service/file_cleaner.py index 73d842d..533c434 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: -- GitLab