Added "--cleanup-index" parameter

This commit is contained in:
Profitroll 2022-08-09 11:56:01 +02:00
parent f790cafbef
commit e0ecf98443
1 changed files with 5 additions and 1 deletions

View File

@ -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")