Skip to content

Commit

Permalink
Commit if we've got outstanding MetadataFile instances
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed Oct 26, 2023
1 parent ca5132d commit d7beda0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/galaxy/model/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,16 @@ def wrap(self, value, session):
if isinstance(value, int):
return session.query(galaxy.model.MetadataFile).get(value)
else:
return session.query(galaxy.model.MetadataFile).filter_by(uuid=value).one()
wrapped_value = session.query(galaxy.model.MetadataFile).filter_by(uuid=value).one_or_none()
if wrapped_value:
return wrapped_value
else:
# If we've simultaneously copied the dataset and we've changed the datatype on the
# copy we may not have committed the MetadataFile yet, so we need to commit the session.
# TODO: It would be great if we can avoid the commit in the future.
with transaction(session):
session.commit()
return session.query(galaxy.model.MetadataFile).filter_by(uuid=value).one_or_none()

def make_copy(self, value, target_context: MetadataCollection, source_context):
session = target_context._object_session(target_context.parent)
Expand Down

0 comments on commit d7beda0

Please sign in to comment.