Skip to content

Commit

Permalink
fix: Fixed handling of no-updates flag
Browse files Browse the repository at this point in the history
  • Loading branch information
monotasker committed Nov 7, 2024
1 parent 8df0c85 commit f0553ff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 9 additions & 0 deletions invenio_record_importer_kcworks/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ def __init__(self, message):
self.message = message


class NoUpdates(Exception):
"""No updates error."""

def __init__(self, message):
"""Initialize the exception."""
super(NoUpdates, self).__init__(message)
self.message = message


class PublicationValidationError(Exception):
"""Publication validation error."""

Expand Down
8 changes: 5 additions & 3 deletions invenio_record_importer_kcworks/record_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from invenio_record_importer_kcworks.errors import (
DraftDeletionFailedError,
ExistingRecordNotUpdatedError,
NoUpdates,
PublicationValidationError,
SkipRecord,
UpdateValidationError,
Expand Down Expand Up @@ -305,9 +306,9 @@ def create_invenio_record(
f" record: {differences['B']}"
)
if no_updates:
raise RuntimeError(
raise NoUpdatesError(
"no_updates flag is set, so not updating existing"
" record"
" record with changed metadata..."
)
update_payload = existing_metadata.copy()
for key, val in differences["B"].items():
Expand Down Expand Up @@ -1475,6 +1476,7 @@ def load_records_into_invenio(
"TooManyViewEventsError": msg,
"TooManyDownloadEventsError": msg,
"UpdateValidationError": msg,
"NoUpdatesError": msg,
}
log_object = {
"index": current_record,
Expand All @@ -1488,7 +1490,7 @@ def load_records_into_invenio(
log_object.update(
{"reason": error_reasons[e.__class__.__name__]}
)
if e.__class__.__name__ != "SkipRecord":
if e.__class__.__name__ not in ["SkipRecord", "NoUpdates"]:
failed_records, residual_failed_records = (
_log_failed_record(
**log_object, skipped_records=skipped_records
Expand Down

0 comments on commit f0553ff

Please sign in to comment.