From 9cac0218540c11f6b667d24dd2b29bba2fd0b899 Mon Sep 17 00:00:00 2001 From: profitroll Date: Tue, 9 Aug 2022 11:45:52 +0200 Subject: [PATCH] Added --cleanup arg --- main.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/main.py b/main.py index 74b8d9d..eb3273a 100644 --- a/main.py +++ b/main.py @@ -23,18 +23,21 @@ if "--move-sent" in sys.argv: logWrite(f"Could not move sent file '{entry}' to '{configGet('sent', 'locations')}' due to {exp}") if "--cleanup" in sys.argv: - for entry in jsonLoad(configGet("index", "locations"))["sent"]: - try: + if "--confirm" in sys.argv: + for entry in jsonLoad(configGet("index", "locations"))["sent"]: try: - os.remove(configGet("queue", "locations")+os.sep+entry) - except FileNotFoundError: - pass - try: - os.remove(configGet("sent", "locations")+os.sep+entry) - except FileNotFoundError: - pass - except Exception as exp: - logWrite(f"Could not remove '{entry}' due to {exp}") + try: + os.remove(configGet("queue", "locations")+os.sep+entry) + except FileNotFoundError: + pass + try: + os.remove(configGet("sent", "locations")+os.sep+entry) + except FileNotFoundError: + pass + except Exception as exp: + logWrite(f"Could not remove '{entry}' due to {exp}") + else: + logWrite(f"Requested cleanup of sent files but not authorized. Please pass '--confirm' to perform that") if "--norun" in sys.argv: logWrite("Argument --norun passed, not running the main script")