mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-07 23:35:22 +01:00
Don't explode on invalid dates
This commit is contained in:
parent
676c8f9fa7
commit
7223ea3c3f
2 changed files with 9 additions and 1 deletions
|
|
@ -394,7 +394,10 @@ class FileInfo(object):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_created(cls, created):
|
def _get_created(cls, created):
|
||||||
|
try:
|
||||||
return dateutil.parser.parse("{:0<14}Z".format(created[:-1]))
|
return dateutil.parser.parse("{:0<14}Z".format(created[:-1]))
|
||||||
|
except ValueError:
|
||||||
|
return None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_correspondent(cls, name):
|
def _get_correspondent(cls, name):
|
||||||
|
|
|
||||||
|
|
@ -359,3 +359,8 @@ class TestFieldPermutations(TestCase):
|
||||||
}
|
}
|
||||||
self._test_guessed_attributes(
|
self._test_guessed_attributes(
|
||||||
template.format(**spec), **spec)
|
template.format(**spec), **spec)
|
||||||
|
|
||||||
|
def test_invalid_date_format(self):
|
||||||
|
info = FileInfo.from_path("/path/to/06112017Z - title.pdf")
|
||||||
|
self.assertEqual(info.title, "title")
|
||||||
|
self.assertIsNone(info.created)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue