mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merge pull request #16931 from mvdbeek/skip_datatype_change
[23.1] Skip change_datatype things if we're not actually changing the extension
This commit is contained in:
@@ -590,13 +590,14 @@ class Registry:
|
||||
return self.datatypes_by_extension.get(ext, None)
|
||||
|
||||
def change_datatype(self, data, ext):
|
||||
data.extension = ext
|
||||
# call init_meta and copy metadata from itself. The datatype
|
||||
# being converted *to* will handle any metadata copying and
|
||||
# initialization.
|
||||
if data.has_data():
|
||||
data.set_size()
|
||||
data.init_meta(copy_from=data)
|
||||
if data.extension != ext:
|
||||
data.extension = ext
|
||||
# call init_meta and copy metadata from itself. The datatype
|
||||
# being converted *to* will handle any metadata copying and
|
||||
# initialization.
|
||||
if data.has_data():
|
||||
data.set_size()
|
||||
data.init_meta(copy_from=data)
|
||||
return data
|
||||
|
||||
def load_datatype_converters(self, toolbox, use_cached=False):
|
||||
|
||||
@@ -604,7 +604,16 @@ class FileParameter(MetadataParameter):
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user