From 994be2f49aae86b362c91ea930f07b0a68f839ec Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Wed, 22 May 2024 11:59:00 +0200 Subject: [PATCH] Do not fail hard when one history fails to be made private --- .../webapps/galaxy/controllers/history.py | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/galaxy/webapps/galaxy/controllers/history.py b/lib/galaxy/webapps/galaxy/controllers/history.py index 4d81338d3b08..1511cde700a4 100644 --- a/lib/galaxy/webapps/galaxy/controllers/history.py +++ b/lib/galaxy/webapps/galaxy/controllers/history.py @@ -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}." }