Skip to content

Commit

Permalink
Do not fail hard when one history fails to be made private
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed May 22, 2024
1 parent 4e03914 commit 994be2f
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions lib/galaxy/webapps/galaxy/controllers/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,20 +192,24 @@ def make_private(self, trans, history_id=None, all_histories=False, **kwd):
trans.app.security_agent.permitted_actions.DATASET_ACCESS: [private_role],
}
for history in histories:
self.history_manager.error_unless_mutable(history)
# Set default role for history to private
trans.app.security_agent.history_set_default_permissions(history, private_permissions)
# Set private role for all datasets
for hda in history.datasets:
if (
not hda.dataset.library_associations
and not trans.app.security_agent.dataset_is_private_to_user(trans, hda.dataset)
and trans.app.security_agent.can_manage_dataset(user_roles, hda.dataset)
):
# If it's not private to me, and I can manage it, set fixed private permissions.
trans.app.security_agent.set_all_dataset_permissions(hda.dataset, private_permissions)
if not trans.app.security_agent.dataset_is_private_to_user(trans, hda.dataset):
raise exceptions.InternalServerError("An error occurred and the dataset is NOT private.")
try:
self.history_manager.error_unless_mutable(history)
# Set default role for history to private
trans.app.security_agent.history_set_default_permissions(history, private_permissions)
# Set private role for all datasets
for hda in history.datasets:
if (
not hda.dataset.library_associations
and not trans.app.security_agent.dataset_is_private_to_user(trans, hda.dataset)
and trans.app.security_agent.can_manage_dataset(user_roles, hda.dataset)
):
# If it's not private to me, and I can manage it, set fixed private permissions.
trans.app.security_agent.set_all_dataset_permissions(hda.dataset, private_permissions)
if not trans.app.security_agent.dataset_is_private_to_user(trans, hda.dataset):
raise exceptions.InternalServerError("An error occurred and the dataset is NOT private.")
except Exception:
log.exception("Error making datasets private.")
continue
return {
"message": f"Success, requested permissions have been changed in {'all histories' if all_histories else history.name}."
}
Expand Down

0 comments on commit 994be2f

Please sign in to comment.