Skip to content

Commit

Permalink
Engine uploads convert ':' to '/'
Browse files Browse the repository at this point in the history
  • Loading branch information
hkethi002 committed Feb 28, 2018
1 parent d55d706 commit 9668287
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 3 additions & 1 deletion api/placer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down
17 changes: 15 additions & 2 deletions tests/integration_tests/python/test_uploads.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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']
Expand Down

0 comments on commit 9668287

Please sign in to comment.