Skip to content

Commit

Permalink
De-duplicate and sort metadata and ACLs before updating
Browse files Browse the repository at this point in the history
This improves efficiency and sorting makes operations consistent.
  • Loading branch information
kjsanger committed Aug 17, 2023
1 parent 104e39b commit b699e66
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/npg_irods/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ def update_metadata(item: Collection | DataObject, avus: list[AVU]) -> bool:
True if any changes were made, False if the desired metadata were already
present.
"""
avus = sorted(set(avus)) # Ensure no duplicates, sort for reproducibility

log.info("Updating metadata", path=item, meta=avus)
num_removed, num_added = item.supersede_metadata(*avus, history=True)
log.info(
Expand Down Expand Up @@ -248,6 +250,8 @@ def update_permissions(
f"Cannot recursively update permissions on a data object: {item}"
)

acl = sorted(set(acl)) # Ensure no duplicates, sort for reproducibility

if has_mixed_ownership(acl):
log.warn("Mixed-study data", path=item, acl=acl)
for ac in acl:
Expand Down

0 comments on commit b699e66

Please sign in to comment.