diff --git a/src/documents/consumer.py b/src/documents/consumer.py index cc23a5b46..411e9f2db 100644 --- a/src/documents/consumer.py +++ b/src/documents/consumer.py @@ -293,6 +293,9 @@ class Consumer(object): self.log("debug", "Saving record to database") + created = file_info.created or timezone.make_aware( + datetime.datetime.fromtimestamp(stats.st_mtime)) + with open(doc, "rb") as f: document = Document.objects.create( correspondent=file_info.correspondent, @@ -300,10 +303,8 @@ class Consumer(object): content=text, file_type=file_info.extension, checksum=hashlib.md5(f.read()).hexdigest(), - created=timezone.make_aware( - datetime.datetime.fromtimestamp(stats.st_mtime)), - modified=timezone.make_aware( - datetime.datetime.fromtimestamp(stats.st_mtime)) + created=created, + modified=created ) relevant_tags = set(list(Tag.match_all(text)) + list(file_info.tags)) diff --git a/src/documents/models.py b/src/documents/models.py index 6dd2cbb63..d4659c57e 100644 --- a/src/documents/models.py +++ b/src/documents/models.py @@ -376,6 +376,7 @@ class FileInfo(object): """ We use a crude naming convention to make handling the correspondent, title, and tags easier: + " - - - <tags>.<suffix>" "<correspondent> - <title> - <tags>.<suffix>" "<correspondent> - <title>.<suffix>" "<title>.<suffix>" diff --git a/src/documents/tests/test_consumer.py b/src/documents/tests/test_consumer.py index 7bfde733a..7e303c5da 100644 --- a/src/documents/tests/test_consumer.py +++ b/src/documents/tests/test_consumer.py @@ -3,7 +3,7 @@ from django.test import TestCase from ..models import FileInfo -class TestAttachment(TestCase): +class TestAttributes(TestCase): TAGS = ("tag1", "tag2", "tag3") EXTENSIONS = ( @@ -154,7 +154,6 @@ class Permutations(TestCase): correspondent=None, title=None, extension=None, tags=None): - # print(filename) info = FileInfo.from_path(filename) # Created