]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fail consumption when duplicate ASN is given
authorPeter Kappelt <kappelt.peter@gmail.com>
Mon, 16 Jan 2023 13:26:41 +0000 (14:26 +0100)
committerTrenton H <797416+stumpylog@users.noreply.github.com>
Tue, 24 Jan 2023 17:43:52 +0000 (09:43 -0800)
(rather than just logging warning)

src-ui/src/app/services/consumer-status.service.ts
src/documents/consumer.py

index 176227bef0b3aa832700b43f4d3971a39088c424..51c4292b4fb06f7e6acf78fbfdaa973aee0f6f5a 100644 (file)
@@ -13,6 +13,7 @@ export enum FileStatusPhase {
 
 export const FILE_STATUS_MESSAGES = {
   document_already_exists: $localize`Document already exists.`,
+  asn_already_exists: $localize`Document with ASN already exists.`,
   file_not_found: $localize`File not found.`,
   pre_consume_script_not_found: $localize`:Pre-Consume is a term that appears like that in the documentation as well and does not need a specific translation:Pre-consume script does not exist.`,
   pre_consume_script_error: $localize`:Pre-Consume is a term that appears like that in the documentation as well and does not need a specific translation:Error while executing pre-consume script.`,
index aec215e7cf8efe2dde4c936614cf91a214b0258a..12552bf67e985ff5a809f46742fc6a8ee89a0879 100644 (file)
@@ -39,6 +39,7 @@ class ConsumerError(Exception):
 
 
 MESSAGE_DOCUMENT_ALREADY_EXISTS = "document_already_exists"
+MESSAGE_ASN_ALREADY_EXISTS = "asn_already_exists"
 MESSAGE_FILE_NOT_FOUND = "file_not_found"
 MESSAGE_PRE_CONSUME_SCRIPT_NOT_FOUND = "pre_consume_script_not_found"
 MESSAGE_PRE_CONSUME_SCRIPT_ERROR = "pre_consume_script_error"
@@ -139,12 +140,10 @@ class Consumer(LoggingMixin):
             # check not necessary in case no ASN gets set
             return
         if Document.objects.filter(archive_serial_number=self.override_asn).exists():
-            self.log(
-                "warning",
-                f"A document with ASN {self.override_asn} already exists. "
-                + "No ASN will be set!",
+            self._fail(
+                MESSAGE_ASN_ALREADY_EXISTS,
+                f"Not consuming {self.filename}: Given ASN already" f"exists!",
             )
-            self.override_asn = None
 
     def run_pre_consume_script(self):
         if not settings.PRE_CONSUME_SCRIPT: