Skip to content

Commit

Permalink
files: fix record retrieval from the file bucket
Browse files Browse the repository at this point in the history
- Adds cryptograpy exceptions.
- Replaces the hard coded filter by the list of known REST endpoints when a record is
  retrieved for a given bucket.

Co-Authored-by: Johnny Mariéthoz <Johnny.Mariethoz@rero.ch>
  • Loading branch information
jma committed Sep 27, 2023
1 parent ffb091c commit d7eef23
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ fi
# | celery | 5.1.2 | <5.2.2 | 43738 |
# | cryptography | 39.0.2 | <41.0.0 | 59062 |
# | cryptography | 39.0.2 | <41.0.2 | 59473 |
# | cryptography | 39.0.2 | >=0.8, <41.0.3 | 60224 |
# | cryptography | 39.0.2 | >=0.8, <41.0.3 | 60225 |
# | cryptography | 39.0.2 | >=0.8,<41.0.3 | 60223 |
# | certifi | 2022.12.7 | >=2015.04.28,<2023.07.22 | 59956 |
# +==============================================================================+
safety check -i 45183 -i 44501 -i 51668 -i 42194 -i 42852 -i 53325 -i 53326 -i 54456 -i 42498 -i 43738 -i 47833 -i 51457 -i 51358 -i 53812 -i 52495 -i 50792 -i 55261 -i 59062 -i 59473 -i 59956
safety check -i 45183 -i 44501 -i 51668 -i 42194 -i 42852 -i 53325 -i 53326 -i 54456 -i 42498 -i 43738 -i 47833 -i 51457 -i 51358 -i 53812 -i 52495 -i 50792 -i 55261 -i 59062 -i 59473 -i 59956 -i 60223 -i 60224 -i 60225
pydocstyle sonar tests docs
isort --check-only --diff "${SCRIPT_PATH}/.."
autoflake -c -r --remove-all-unused-imports --ignore-init-module-imports . &> /dev/null || {
Expand Down
9 changes: 8 additions & 1 deletion sonar/modules/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,16 @@ def get_record_by_bucket(bucket):
raise Exception('`records_buckets` object not found.')

# Find the record PID.

# Filter by the declared REST endpoints to avoid identifiers as
# oai, urn, etc.
pid_types = [
v['pid_type'] for v in
current_app.config.get('RECORDS_REST_ENDPOINTS',{}).values()
]
pid = PersistentIdentifier.query.filter_by(
object_uuid=records_buckets.record_id).filter(
~PersistentIdentifier.pid_type.in_(['oai', 'rerod'])
PersistentIdentifier.pid_type.in_(pid_types)
).first()

if not pid:
Expand Down

0 comments on commit d7eef23

Please sign in to comment.