From e0ecf984435336b267b5d7bf7b984a5b58924814 Mon Sep 17 00:00:00 2001 From: profitroll Date: Tue, 9 Aug 2022 11:56:01 +0200 Subject: [PATCH] Added "--cleanup-index" parameter --- main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index f5767f1..15aeda6 100644 --- a/main.py +++ b/main.py @@ -25,7 +25,8 @@ if "--move-sent" in sys.argv: if "--cleanup" in sys.argv: if "--confirm" in sys.argv: - for entry in jsonLoad(configGet("index", "locations"))["sent"]: + index = jsonLoad(configGet("index", "locations")) + for entry in index["sent"]: try: try: os.remove(configGet("queue", "locations")+os.sep+entry) @@ -35,8 +36,11 @@ if "--cleanup" in sys.argv: os.remove(configGet("sent", "locations")+os.sep+entry) except FileNotFoundError: pass + if "--cleanup-index" in sys.argv: + del index[entry] except Exception as exp: logWrite(f"Could not remove '{entry}' due to {exp}") + jsonSave(index, jsonLoad(configGet("index", "locations"))) logWrite(f"Performed cleanup of the sent files") else: logWrite(f"Requested cleanup of sent files but not authorized. Please pass '--confirm' to perform that")