From a000f3b929a6c1dea944d8c087a51f7ec0a020f2 Mon Sep 17 00:00:00 2001 From: John Davis Date: Thu, 1 Jun 2023 21:51:53 -0400 Subject: [PATCH] Wrap session.flush in TS util.metadata_util --- lib/tool_shed/util/metadata_util.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/tool_shed/util/metadata_util.py b/lib/tool_shed/util/metadata_util.py index 9f3ec4347a8..47d82928f0b 100644 --- a/lib/tool_shed/util/metadata_util.py +++ b/lib/tool_shed/util/metadata_util.py @@ -7,6 +7,7 @@ from typing import ( from sqlalchemy import and_ +from galaxy.model.base import transaction from galaxy.tool_shed.util.hg_util import ( INITIAL_CHANGELOG_HASH, reversed_lower_upper_bounded_changelog, @@ -146,7 +147,9 @@ def get_metadata_revisions(app, repository, sort_revisions=True, reverse=False, rev = changeset2rev(repo_path, repository_metadata.changeset_revision) repository_metadata.numeric_revision = rev sa_session.add(repository_metadata) - sa_session.flush() + session = sa_session() + with transaction(session): + session.commit() except Exception: rev = -1 else: @@ -269,7 +272,9 @@ def repository_metadata_by_changeset_revision( # Delete all records older than the last one updated. for repository_metadata in all_metadata_records[1:]: sa_session.delete(repository_metadata) - sa_session.flush() + session = sa_session() + with transaction(session): + session.commit() return all_metadata_records[0] elif all_metadata_records: return all_metadata_records[0]