fix: alert for failed deletions

This commit is contained in:
Ben Goldsworthy 2024-03-15 21:36:47 +01:00
parent 0d6c9907e5
commit e2ac8e18f0
Signed by: Rumperuu
SSH key fingerprint: SHA256:e5XfzNOr9UvWpEzyLfw0GtTMZWIFh3NmxH+/qQIi3xE

View file

@ -118,6 +118,8 @@ def delete_existing(item_id: str, media_type: str, log: str) -> None:
] ]
if len(log_items) < (old_len - 1): if len(log_items) < (old_len - 1):
raise Exception("More than one deletion made, discarding…") raise Exception("More than one deletion made, discarding…")
elif len(log_items) == old_len:
raise Exception("No item deleted, skipping…"s)
with open(f"./data/{media_type}/{log}.json", "w", encoding="utf-8") as log_file: with open(f"./data/{media_type}/{log}.json", "w", encoding="utf-8") as log_file:
json.dump(log_items, log_file, indent=4) json.dump(log_items, log_file, indent=4)