mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Merge pull request #143 from danielquinn/issue/121
Actually write the date found in the file name. Closes #121.
This commit is contained in:
commit
53909cf9b0
@ -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))
|
||||
|
@ -376,6 +376,7 @@ class FileInfo(object):
|
||||
"""
|
||||
We use a crude naming convention to make handling the correspondent,
|
||||
title, and tags easier:
|
||||
"<date> - <correspondent> - <title> - <tags>.<suffix>"
|
||||
"<correspondent> - <title> - <tags>.<suffix>"
|
||||
"<correspondent> - <title>.<suffix>"
|
||||
"<title>.<suffix>"
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user