diff --git a/modules/daemon/task.py b/modules/daemon/task.py index 4f8222d..4b69564 100644 --- a/modules/daemon/task.py +++ b/modules/daemon/task.py @@ -8,10 +8,10 @@ DB_PATH = Path("./data/tasks.json") try: - db = pickledb.load(DB_PATH, False) + db = pickledb.load(DB_PATH, True) except Exception: DB_PATH.unlink() - db = pickledb.load(DB_PATH, False) + db = pickledb.load(DB_PATH, True) def create_background_task( diff --git a/modules/importers/methods/e621/e621.py b/modules/importers/methods/e621/e621.py index 1b342c5..8b145cd 100644 --- a/modules/importers/methods/e621/e621.py +++ b/modules/importers/methods/e621/e621.py @@ -6,6 +6,7 @@ from itertools import islice from tqdm import tqdm from pathlib import Path +import logging import requests @@ -29,6 +30,8 @@ async def load(self, limit:Union[int, None] = None): await load_post(data) except ImportFailure: pass + except Exception as e: + logging.exception(e) async def load_post(data:dict): diff --git a/modules/importers/methods/rule34/rule34.py b/modules/importers/methods/rule34/rule34.py index 40b0650..58b0f76 100644 --- a/modules/importers/methods/rule34/rule34.py +++ b/modules/importers/methods/rule34/rule34.py @@ -3,7 +3,7 @@ from modules import settings, schemas, database from tqdm.asyncio import tqdm from typing import Union -from itertools import islice +import logging class Rule34(Importer): @@ -23,6 +23,8 @@ async def load(self, limit:Union[int, None] = None): await load_post(post) except ImportFailure: continue + except Exception as e: + logging.exception(e) diff --git a/modules/posts/insert.py b/modules/posts/insert.py index f6a5223..99e6bbf 100644 --- a/modules/posts/insert.py +++ b/modules/posts/insert.py @@ -8,6 +8,7 @@ def insert(post: schemas.Post, validate=True): if validate: _validate_post(post) + database.Post.insert(post) if post.uploader: database.User.create_post(post.uploader, post.id) diff --git a/requirements.txt b/requirements.txt index c3ebddc..881d4ff 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,6 +14,7 @@ cachetools pymongo jinja2 boto3 +pickledb # Encoding pillow