diff --git a/api/placer.py b/api/placer.py index b0e5e8c03..04c6c2e7f 100644 --- a/api/placer.py +++ b/api/placer.py @@ -295,6 +295,8 @@ def process_file_field(self, field, file_attrs): if not job_ticket['success']: file_attrs['from_failed_job'] = True + file_attrs['name'] = file_attrs['name'].replace(':', '/') + self.save_file(field, file_attrs) self.saved.append(file_attrs) @@ -314,7 +316,7 @@ def finalize(self): file_mds = self.metadata.get(self.container_type, {}).get('files', []) saved_file_names = [x.get('name') for x in self.saved] for file_md in file_mds: - if file_md['name'] not in saved_file_names: + if file_md['name'].replace(':', '/') not in saved_file_names: self.save_file(None, file_md) # save file_attrs update only self.saved.append(file_md) diff --git a/tests/integration_tests/python/test_uploads.py b/tests/integration_tests/python/test_uploads.py index d97fa8b8b..9da192c33 100644 --- a/tests/integration_tests/python/test_uploads.py +++ b/tests/integration_tests/python/test_uploads.py @@ -701,10 +701,23 @@ def test_acquisition_engine_upload(data_builder, file_form, as_root): ) assert r.status_code == 404 + metadata['acquisition']['files'] = [ + { + 'name': 'one.csv', + 'type': 'engine type 0', + 'info': {'test': 'f0'} + }, + { + 'name': 'folder:two.csv', + 'type': 'engine type 1', + 'info': {'test': 'f1'} + } + ] + # engine upload r = as_root.post('/engine', params={'level': 'acquisition', 'id': acquisition, 'job': job}, - files=file_form('one.csv', 'two.csv', meta=metadata) + files=file_form('one.csv', 'folder:two.csv', meta=metadata) ) assert r.ok @@ -734,7 +747,7 @@ def test_acquisition_engine_upload(data_builder, file_form, as_root): assert a_timestamp == m_timestamp for mf in metadata['acquisition']['files']: - f = find_file_in_array(mf['name'], a['files']) + f = find_file_in_array(mf['name'].replace(':', '/'), a['files']) assert mf is not None assert f['type'] == mf['type'] assert f['info'] == mf['info']