From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Thu, 17 Nov 2022 21:37:37 +0000 (-0800) Subject: Don't allow an exception when trying to parse a date cause complete failure X-Git-Tag: v1.10.0-beta.rc2~6^2 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1998%2Fhead;p=thirdparty%2Fpaperless-ngx.git Don't allow an exception when trying to parse a date cause complete failure --- diff --git a/src/documents/consumer.py b/src/documents/consumer.py index f542a1d98a..d813801919 100644 --- a/src/documents/consumer.py +++ b/src/documents/consumer.py @@ -444,7 +444,12 @@ class Consumer(LoggingMixin): return document - def _store(self, text, date, mime_type) -> Document: + def _store( + self, + text: str, + date: Optional[datetime.datetime], + mime_type: str, + ) -> Document: # If someone gave us the original filename, use it instead of doc. diff --git a/src/documents/parsers.py b/src/documents/parsers.py index f621996775..e2309b3665 100644 --- a/src/documents/parsers.py +++ b/src/documents/parsers.py @@ -260,7 +260,7 @@ def parse_date_generator(filename, text) -> Iterator[datetime.datetime]: try: date = __parser(date_string, date_order) - except (TypeError, ValueError): + except Exception: # Skip all matches that do not parse to a proper date date = None