mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Fail consumption when duplicate ASN is given
(rather than just logging warning)
This commit is contained in:
		| @@ -13,6 +13,7 @@ export enum FileStatusPhase { | |||||||
|  |  | ||||||
| export const FILE_STATUS_MESSAGES = { | export const FILE_STATUS_MESSAGES = { | ||||||
|   document_already_exists: $localize`Document already exists.`, |   document_already_exists: $localize`Document already exists.`, | ||||||
|  |   asn_already_exists: $localize`Document with ASN already exists.`, | ||||||
|   file_not_found: $localize`File not found.`, |   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_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.`, |   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.`, | ||||||
|   | |||||||
| @@ -39,6 +39,7 @@ class ConsumerError(Exception): | |||||||
|  |  | ||||||
|  |  | ||||||
| MESSAGE_DOCUMENT_ALREADY_EXISTS = "document_already_exists" | MESSAGE_DOCUMENT_ALREADY_EXISTS = "document_already_exists" | ||||||
|  | MESSAGE_ASN_ALREADY_EXISTS = "asn_already_exists" | ||||||
| MESSAGE_FILE_NOT_FOUND = "file_not_found" | MESSAGE_FILE_NOT_FOUND = "file_not_found" | ||||||
| MESSAGE_PRE_CONSUME_SCRIPT_NOT_FOUND = "pre_consume_script_not_found" | MESSAGE_PRE_CONSUME_SCRIPT_NOT_FOUND = "pre_consume_script_not_found" | ||||||
| MESSAGE_PRE_CONSUME_SCRIPT_ERROR = "pre_consume_script_error" | 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 |             # check not necessary in case no ASN gets set | ||||||
|             return |             return | ||||||
|         if Document.objects.filter(archive_serial_number=self.override_asn).exists(): |         if Document.objects.filter(archive_serial_number=self.override_asn).exists(): | ||||||
|             self.log( |             self._fail( | ||||||
|                 "warning", |                 MESSAGE_ASN_ALREADY_EXISTS, | ||||||
|                 f"A document with ASN {self.override_asn} already exists. " |                 f"Not consuming {self.filename}: Given ASN already" f"exists!", | ||||||
|                 + "No ASN will be set!", |  | ||||||
|             ) |             ) | ||||||
|             self.override_asn = None |  | ||||||
|  |  | ||||||
|     def run_pre_consume_script(self): |     def run_pre_consume_script(self): | ||||||
|         if not settings.PRE_CONSUME_SCRIPT: |         if not settings.PRE_CONSUME_SCRIPT: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Peter Kappelt
					Peter Kappelt