diff --git a/README.md b/README.md index ea61ede..06b9b4b 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/main.py b/main.py index 15aeda6..0fcd6b4 100644 --- a/main.py +++ b/main.py @@ -36,8 +36,6 @@ 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"))) @@ -45,6 +43,15 @@ if "--cleanup" in sys.argv: 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()