From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Tue, 22 Nov 2022 18:11:27 +0000 (-0800) Subject: If override_date is provided, coerce it into a datetime X-Git-Tag: v1.10.0-beta.rc2~1^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2023%2Fhead;p=thirdparty%2Fpaperless-ngx.git If override_date is provided, coerce it into a datetime --- diff --git a/src/documents/tasks.py b/src/documents/tasks.py index 667c3d9dfc..f5bad665ad 100644 --- a/src/documents/tasks.py +++ b/src/documents/tasks.py @@ -3,6 +3,7 @@ import logging import os import shutil import uuid +from datetime import datetime from pathlib import Path from typing import Type @@ -98,6 +99,14 @@ def consume_file( path = Path(path).resolve() + # Celery converts this to a string, but everything expects a datetime + # Long term solution is to not use JSON for the serializer but pickle instead + if override_created is not None and isinstance(override_created, str): + try: + override_created = datetime.fromisoformat(override_created) + except Exception: + pass + # check for separators in current document if settings.CONSUMER_ENABLE_BARCODES: