Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Merge branch 'dev' into feature-ocrmypdf

jonaswinkler39c682dc07a3
diff --cc src/documents/consumer.py
index 7cdccc2e7,1842fbb56..1accc423f
--- a/src/documents/consumer.py
+++ b/src/documents/consumer.py
@@@ -177,22 -164,16 +177,29 @@@ class Consumer(LoggingMixin)
# place. If this fails, we'll also rollback the transaction.
create_source_path_directory(document.source_path)
- self._write(document, self.path, document.source_path)
- self._write(document, thumbnail, document.thumbnail_path)
+
+ self._write(document.storage_type,
+ self.path, document.source_path)
+
+ self._write(document.storage_type,
+ thumbnail, document.thumbnail_path)
+
+ if archive_path and os.path.isfile(archive_path):
+ self._write(document.storage_type,
+ archive_path, document.archive_path)
+
+ with open(archive_path, 'rb') as f:
+ document.archive_checksum = hashlib.md5(
+ f.read()).hexdigest()
+ document.save()
+ # Afte performing all database operations and moving files
+ # into place, tell paperless where the file is.
+ document.filename = os.path.basename(document.source_path)
+ # Saving the document now will trigger the filename handling
+ # logic.
+ document.save()
+
# Delete the file only if it was successfully consumed
self.log("debug", "Deleting file {}".format(self.path))
os.unlink(self.path)