]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
more sanity checks regarding archive versions
authorjonaswinkler <jonas.winkler@jpwinkler.de>
Tue, 9 Feb 2021 18:46:59 +0000 (19:46 +0100)
committerjonaswinkler <jonas.winkler@jpwinkler.de>
Tue, 9 Feb 2021 18:46:59 +0000 (19:46 +0100)
src/documents/sanity_checker.py

index 0b385e81bf7c41102735e3139b7cb75a169c9b43..61e927c8291394d25aca09cdb91aa0cc42298583 100644 (file)
@@ -87,6 +87,18 @@ def check_sanity():
                         f"Stored: {doc.checksum}, actual: {checksum}."
                     ))
 
+        if doc.archive_checksum and not doc.archive_filename:
+            messages.append(SanityError(
+                f"Document {doc.pk} has an archive file checksum, but no "
+                f"archive filename."
+            ))
+
+        if not doc.archive_checksum and doc.archive_filename:
+            messages.append(SanityError(
+                f"Document {doc.pk} has an archive file, but its checksum is "
+                f"missing."
+            ))
+
         # Check sanity of the archive file.
         if doc.has_archive_version:
             if not os.path.isfile(doc.archive_path):