Compare commits

...

2 Commits

Author SHA1 Message Date
Profitroll 71d1efa82b "--cleanup-index" reformation 2022-08-09 11:58:40 +02:00
Profitroll e0ecf98443 Added "--cleanup-index" parameter 2022-08-09 11:56:01 +02:00
2 changed files with 13 additions and 1 deletions

View File

@ -34,6 +34,7 @@ To make this bot run at first you need to have a Python interpreter and git. Goo
Of course bot also has them. You can perform some actions with them.
* `--move-sent` - allows you to move all sent files from queue to sent directories
* `--cleanup` - purge files in both `queue` and `sent` folders if they're sent. Requires `--confirm` argument
* `--cleanup-index` - purge all sent entries from index. Requires `--confirm` argument
* `--norun` - allows you to execute above arguments without tiggering the bot start itself
Examples:

13
main.py
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)
@ -37,10 +38,20 @@ if "--cleanup" in sys.argv:
pass
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")
if "--cleanup-index" in sys.argv:
if "--confirm" in sys.argv:
index = jsonLoad(configGet("index", "locations"))
index["sent"] = []
jsonSave(index, jsonLoad(configGet("index", "locations")))
logWrite(f"Performed cleanup of sent files index")
else:
logWrite(f"Requested cleanup of sent files index but not authorized. Please pass '--confirm' to perform that")
if "--norun" in sys.argv:
logWrite("Argument --norun passed, not running the main script")
sys.exit()