Core elements, migration, consumer modifications

This commit is contained in:
shamoon
2026-01-18 11:40:43 -08:00
parent 62248f5702
commit 1e595a5aab
11 changed files with 174 additions and 44 deletions

View File

@@ -785,20 +785,16 @@ class ConsumerPreflightPlugin(
Q(checksum=checksum) | Q(archive_checksum=checksum),
)
if existing_doc.exists():
msg = ConsumerStatusShortMessage.DOCUMENT_ALREADY_EXISTS
log_msg = f"Not consuming {self.filename}: It is a duplicate of {existing_doc.get().title} (#{existing_doc.get().pk})."
if existing_doc.first().deleted_at is not None:
msg = ConsumerStatusShortMessage.DOCUMENT_ALREADY_EXISTS_IN_TRASH
log_msg += " Note: existing document is in the trash."
if settings.CONSUMER_DELETE_DUPLICATES:
Path(self.input_doc.original_file).unlink()
self._fail(
msg,
log_msg,
log_msg = (
f"Consuming duplicate {self.filename}: "
f"{existing_doc.count()} existing document(s) share the same content."
)
if existing_doc.filter(deleted_at__isnull=False).exists():
log_msg += " Note: at least one existing document is in the trash."
self.log.warning(log_msg)
def pre_check_directories(self):
"""
Ensure all required directories exist before attempting to use them