Skip to content

Commit

Permalink
Fix empty file check timing
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed Sep 12, 2023
1 parent 4a46073 commit 3930c6a
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/galaxy/metadata/set_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ def reset_external_filename(dataset_instance: DatasetInstance):
dataset_instance.dataset.extra_files_path = None


def push_if_necessary(object_store: ObjectStore, dataset: DatasetInstance, external_filename):
# Here we might be updating a disk based objectstore when outputs_to_working_directory is used,
# or a remote object store from its cache path.
# empty files could happen when outputs are discovered from working dir,
# empty file check needed for e.g. test/integration/test_extended_metadata_outputs_to_working_directory.py::test_tools[multi_output_assign_primary]
if os.path.getsize(external_filename):
object_store.update_from_file(dataset.dataset, file_name=external_filename, create=True)


def set_validated_state(dataset_instance):
datatype_validation = validate(dataset_instance)

Expand Down Expand Up @@ -435,15 +444,9 @@ def set_meta(new_dataset_instance, file_dict):
if not object_store or not export_store:
# Can't happen, but type system doesn't know
raise Exception("object_store not built")
if not is_deferred and not link_data_only and os.path.getsize(external_filename):
# Here we might be updating a disk based objectstore when outputs_to_working_directory is used,
# or a remote object store from its cache path.
# empty files could happen when outputs are discovered from working dir,
# empty file check needed for e.g. test/integration/test_extended_metadata_outputs_to_working_directory.py::test_tools[multi_output_assign_primary]
if not is_deferred and not link_data_only:
object_store_update_actions.append(
partial(
object_store.update_from_file, dataset.dataset, file_name=external_filename, create=True
)
partial(push_if_necessary, object_store, dataset, external_filename)
)
object_store_update_actions.append(partial(reset_external_filename, dataset))
object_store_update_actions.append(partial(export_store.add_dataset, dataset))
Expand Down

0 comments on commit 3930c6a

Please sign in to comment.