mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-12 17:04:40 -05:00
Update consumer.py
This commit is contained in:
parent
84b5ef7c34
commit
3c4225979e
@ -145,7 +145,7 @@ class ConsumerPluginMixin:
|
|||||||
):
|
):
|
||||||
self._send_progress(100, 100, ProgressStatusOptions.FAILED, message)
|
self._send_progress(100, 100, ProgressStatusOptions.FAILED, message)
|
||||||
self.log.error(log_message or message, exc_info=exc_info)
|
self.log.error(log_message or message, exc_info=exc_info)
|
||||||
raise ConsumerError(f"{self.filename}: {log_message or message}")
|
raise ConsumerError(f"{self.filename}: {log_message or message}") from exception
|
||||||
|
|
||||||
|
|
||||||
class ConsumerPlugin(
|
class ConsumerPlugin(
|
||||||
@ -535,18 +535,8 @@ class ConsumerPlugin(
|
|||||||
document.save()
|
document.save()
|
||||||
success = True
|
success = True
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as fail_exc:
|
||||||
# save the exception for later
|
store_exception = fail_exc
|
||||||
try:
|
|
||||||
self._fail(
|
|
||||||
str(e),
|
|
||||||
f"The following error occurred while storing document "
|
|
||||||
f"{self.filename} after parsing: {e}",
|
|
||||||
exc_info=True,
|
|
||||||
exception=e,
|
|
||||||
)
|
|
||||||
except Exception as fail_exc:
|
|
||||||
stored_exception = fail_exc
|
|
||||||
finally:
|
finally:
|
||||||
if success:
|
if success:
|
||||||
# Delete the file only if it was successfully consumed
|
# Delete the file only if it was successfully consumed
|
||||||
@ -582,8 +572,14 @@ class ConsumerPlugin(
|
|||||||
document.refresh_from_db()
|
document.refresh_from_db()
|
||||||
|
|
||||||
result = f"Success. New document id {document.pk} created"
|
result = f"Success. New document id {document.pk} created"
|
||||||
elif stored_exception:
|
elif store_exception:
|
||||||
raise stored_exception
|
self._fail(
|
||||||
|
str(store_exception),
|
||||||
|
f"The following error occurred while storing document "
|
||||||
|
f"{self.filename} after parsing: {store_exception}",
|
||||||
|
exc_info=True,
|
||||||
|
exception=store_exception,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
self._fail(
|
self._fail(
|
||||||
ConsumerStatusShortMessage.FAILED,
|
ConsumerStatusShortMessage.FAILED,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user