From 4dbc6b44d4b3667ea7587b9e3cc33351c459e27b Mon Sep 17 00:00:00 2001 From: ArabCoders Date: Sun, 7 Jan 2024 16:50:54 +0300 Subject: [PATCH] Added check for webhook file existing but empty. --- app/Webhooks.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Webhooks.py b/app/Webhooks.py index 989ef45b..b2b7f6e3 100644 --- a/app/Webhooks.py +++ b/app/Webhooks.py @@ -14,10 +14,14 @@ class Webhooks: def __init__(self, file: str): if os.path.exists(file): try: + if os.path.getsize(file) < 2: + raise Exception(f'file is empty.') + log.info(f'Loading webhooks from {file}') with open(file, 'r') as f: self.targets = json.load(f) except Exception as e: + log.error(f'Error loading webhooks from {file}: {e}') pass async def send(self, event: str, item: ItemDTO) -> list[dict]: