Skip to content

Commit

Permalink
SA2.0: Replacde flush with commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Oct 6, 2023
1 parent 7e7cbf1 commit 248b8bb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion lib/tool_shed/webapp/api2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from galaxy.exceptions import AdminRequiredException
from galaxy.managers.session import GalaxySessionManager
from galaxy.managers.users import UserManager
from galaxy.model.base import transaction
from galaxy.security.idencoding import IdEncodingHelper
from galaxy.util import unicodify
from galaxy.web.framework.decorators import require_admin_message
Expand Down Expand Up @@ -331,7 +332,8 @@ def ensure_valid_session(trans: SessionRequestContext) -> None:
# be needed.
if prev_galaxy_session:
sa_session.add(prev_galaxy_session)
sa_session.flush()
with transaction(sa_session):
sa_session.commit()


def set_auth_cookie(trans: SessionRequestContext, session):
Expand Down
13 changes: 9 additions & 4 deletions lib/tool_shed/webapp/api2/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from starlette.datastructures import UploadFile as StarletteUploadFile

from galaxy.exceptions import InsufficientPermissionsException
from galaxy.model.base import transaction
from galaxy.webapps.galaxy.api import as_form
from tool_shed.context import SessionRequestContext
from tool_shed.managers.repositories import (
Expand Down Expand Up @@ -357,7 +358,8 @@ def set_malicious(
repository_metadata = get_repository_metadata_for_management(trans, encoded_repository_id, changeset_revision)
repository_metadata.malicious = True
trans.sa_session.add(repository_metadata)
trans.sa_session.flush()
with transaction(trans.sa_session):
trans.sa_session.commit()
return Response(status_code=status.HTTP_204_NO_CONTENT)

@router.delete(
Expand All @@ -374,7 +376,8 @@ def unset_malicious(
repository_metadata = get_repository_metadata_for_management(trans, encoded_repository_id, changeset_revision)
repository_metadata.malicious = False
trans.sa_session.add(repository_metadata)
trans.sa_session.flush()
with transaction(trans.sa_session):
trans.sa_session.commit()
return Response(status_code=status.HTTP_204_NO_CONTENT)

@router.put(
Expand All @@ -392,7 +395,8 @@ def set_deprecated(
raise InsufficientPermissionsException("You do not have permission to update this repository.")
repository.deprecated = True
trans.sa_session.add(repository)
trans.sa_session.flush()
with transaction(trans.sa_session):
trans.sa_session.commit()
return Response(status_code=status.HTTP_204_NO_CONTENT)

@router.delete(
Expand All @@ -410,7 +414,8 @@ def unset_deprecated(
raise InsufficientPermissionsException("You do not have permission to update this repository.")
repository.deprecated = False
trans.sa_session.add(repository)
trans.sa_session.flush()
with transaction(trans.sa_session):
trans.sa_session.commit()
return Response(status_code=status.HTTP_204_NO_CONTENT)

@router.delete(
Expand Down

0 comments on commit 248b8bb

Please sign in to comment.