]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fix: use unmodified original for checksum if exists (#8693)
authorshamoon <4887959+shamoon@users.noreply.github.com>
Mon, 13 Jan 2025 21:02:10 +0000 (13:02 -0800)
committerGitHub <noreply@github.com>
Mon, 13 Jan 2025 21:02:10 +0000 (21:02 +0000)
src/documents/consumer.py

index f353afbe744949074c1516694a20f5eee44cbe6e..75fa1da1b91b637a9b9482d5d175e416bc6424e4 100644 (file)
@@ -718,11 +718,17 @@ class ConsumerPlugin(
                     f"Error occurred parsing title override '{self.metadata.title}', falling back to original. Exception: {e}",
                 )
 
+        file_for_checksum = (
+            self.unmodified_original
+            if self.unmodified_original is not None
+            else self.working_copy
+        )
+
         document = Document.objects.create(
             title=title[:127],
             content=text,
             mime_type=mime_type,
-            checksum=hashlib.md5(self.working_copy.read_bytes()).hexdigest(),
+            checksum=hashlib.md5(file_for_checksum.read_bytes()).hexdigest(),
             created=create_date,
             modified=create_date,
             storage_type=storage_type,