fixes an issue with paperless not assigning metadata when FILENAME_FORMAT is specified and resolves an invalid warning about missing files fixes #67

This commit is contained in:
jonaswinkler
2020-11-29 14:45:43 +01:00
parent 5160ff9793
commit a27daaebe9
7 changed files with 14 additions and 12 deletions

View File

@@ -167,6 +167,11 @@ class Consumer(LoggingMixin):
self._write(document, self.path, document.source_path)
self._write(document, thumbnail, document.thumbnail_path)
# Afte performing all database operations and moving files
# into place, tell paperless where the file is.
document.filename = generate_filename(document)
document.save()
# Delete the file only if it was successfully consumed
self.log("debug", "Deleting file {}".format(self.path))
os.unlink(self.path)
@@ -217,12 +222,6 @@ class Consumer(LoggingMixin):
self.apply_overrides(document)
document.filename = generate_filename(document)
# We need to save the document twice, since we need the PK of the
# document in order to create its filename above.
document.save()
return document
def apply_overrides(self, document):