Update consumer.py

This commit is contained in:
shamoon 2025-06-26 14:49:08 -07:00
parent ba91bb154a
commit 056b314a89
No known key found for this signature in database

View File

@ -468,7 +468,6 @@ class ConsumerPlugin(
# now that everything is done, we can start to store the document
# in the system. This will be a transaction and reasonably fast.
success = False
result = None
store_exception = None
try:
with transaction.atomic():
@ -572,8 +571,13 @@ class ConsumerPlugin(
# Return the most up to date fields
document.refresh_from_db()
result = f"Success. New document id {document.pk} created"
elif store_exception:
document_parser.cleanup()
tempdir.cleanup()
return f"Success. New document id {document.pk} created"
else:
document_parser.cleanup()
tempdir.cleanup()
if store_exception:
self._fail(
str(store_exception),
f"The following error occurred while storing document "
@ -587,10 +591,6 @@ class ConsumerPlugin(
f"Error occurred while saving {self.filename}.",
)
document_parser.cleanup()
tempdir.cleanup()
return result
def _parse_title_placeholders(self, title: str) -> str:
local_added = timezone.localtime(timezone.now())