diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index 69be939b521e..9495b3a82401 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -1633,7 +1633,10 @@ def add_input_dataset(self, name, dataset=None, dataset_id=None): def add_output_dataset(self, name, dataset): joda = JobToOutputDatasetAssociation(name, dataset) - dataset.dataset.job = self + if dataset.dataset.job is None: + # Only set job if dataset doesn't already have associated job. + # database operation tools that make copies should not modify the job here. + dataset.dataset.job = self add_object_to_object_session(self, joda) self.output_datasets.append(joda)