Added "--cleanup-index" parameter
This commit is contained in:
parent
f790cafbef
commit
e0ecf98443
6
main.py
6
main.py
@ -25,7 +25,8 @@ if "--move-sent" in sys.argv:
|
|||||||
|
|
||||||
if "--cleanup" in sys.argv:
|
if "--cleanup" in sys.argv:
|
||||||
if "--confirm" 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:
|
||||||
try:
|
try:
|
||||||
os.remove(configGet("queue", "locations")+os.sep+entry)
|
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)
|
os.remove(configGet("sent", "locations")+os.sep+entry)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
|
if "--cleanup-index" in sys.argv:
|
||||||
|
del index[entry]
|
||||||
except Exception as exp:
|
except Exception as exp:
|
||||||
logWrite(f"Could not remove '{entry}' due to {exp}")
|
logWrite(f"Could not remove '{entry}' due to {exp}")
|
||||||
|
jsonSave(index, jsonLoad(configGet("index", "locations")))
|
||||||
logWrite(f"Performed cleanup of the sent files")
|
logWrite(f"Performed cleanup of the sent files")
|
||||||
else:
|
else:
|
||||||
logWrite(f"Requested cleanup of sent files but not authorized. Please pass '--confirm' to perform that")
|
logWrite(f"Requested cleanup of sent files but not authorized. Please pass '--confirm' to perform that")
|
||||||
|
Reference in New Issue
Block a user