From 2bd8a3081290cd5440f9f148dc50f5427d940965 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Sat, 19 Aug 2023 10:32:53 +0200 Subject: [PATCH] check for filesize and if empty --- tnc/helpers.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tnc/helpers.py b/tnc/helpers.py index 0e49358c..5521b522 100644 --- a/tnc/helpers.py +++ b/tnc/helpers.py @@ -611,7 +611,15 @@ def delete_last_line_from_hmac_list(filepath, position): def check_if_file_exists(path): try: - return os.path.isfile(path) + # check if file size is present and filesize > 0 + if os.path.isfile(path): + filesize = os.path.getsize(path) + if filesize > 0: + return True + else: + return False + else: + return False except Exception as e: log.warning( "[TNC] [FILE] Lookup failed", e=e, path=path,