Skip to content
Snippets Groups Projects
Commit a257e337 authored by Nathaniel Kofalt's avatar Nathaniel Kofalt
Browse files

Fixes

parent 2631c31d
No related branches found
No related tags found
No related merge requests found
......@@ -81,22 +81,23 @@ class GearHandler(base.RequestHandler):
r = upload.process_upload(self.request, upload.Strategy.gear, container_type='gear', origin=self.origin, metadata=self.request.headers.get('metadata'))
gear_id = upsert_gear(r[1])
config.db.gears.update_one({'_id': gear_id}, {'$set': {
'exchange.rootfs-url': '/api/gears/temp/' + str(gear_id)}
})
return {'_id': str(gear_id)}
# Temporary Function
def download(self, **kwargs):
"""Download gear tarball file"""
if not self.user_is_admin:
self.abort(403, 'Request requires admin')
dl_id = kwargs.pop('cid')
gear = get_gear(dl_id)
hash_ = gear['exchange']['rootfs-hash']
filepath = os.path.join(config.get_item('persistent', 'data_path'), util.path_from_hash(hash_))
filepath = os.path.join(config.get_item('persistent', 'data_path'), util.path_from_hash('v0-' + hash_.replace(':', '-')))
self.response.app_iter = open(filepath, 'rb')
self.response.headers['Content-Length'] = str(gear['size']) # must be set after setting app_iter
# self.response.headers['Content-Length'] = str(gear['size']) # must be set after setting app_iter
self.response.headers['Content-Type'] = 'application/octet-stream'
self.response.headers['Content-Disposition'] = 'attachment; filename="' + gear['filename'] + '"'
self.response.headers['Content-Disposition'] = 'attachment; filename="gear.tar"'
def post(self, _id):
......
......@@ -128,7 +128,6 @@ class TargetedPlacer(Placer):
self.recalc_session_compliance()
return self.saved
class UIDPlacer(Placer):
"""
A placer that can accept multiple files.
......@@ -228,7 +227,6 @@ class LabelPlacer(UIDPlacer):
create_hierarchy = staticmethod(hierarchy.upsert_top_down_hierarchy)
match_type = 'label'
class UIDMatchPlacer(UIDPlacer):
"""
A placer that uploads to an existing hierarchy it finds based on uid.
......@@ -238,7 +236,6 @@ class UIDMatchPlacer(UIDPlacer):
create_hierarchy = staticmethod(hierarchy.find_existing_hierarchy)
match_type = 'uid'
class EnginePlacer(Placer):
"""
A placer that can accept files and/or metadata sent to it from the engine
......@@ -314,7 +311,6 @@ class EnginePlacer(Placer):
self.recalc_session_compliance()
return self.saved
class TokenPlacer(Placer):
"""
A placer that can accept N files and save them to a persistent directory across multiple requests.
......@@ -355,7 +351,6 @@ class TokenPlacer(Placer):
self.recalc_session_compliance()
return self.saved
class PackfilePlacer(Placer):
"""
A placer that can accept N files, save them into a zip archive, and place the result on an acquisition.
......@@ -678,22 +673,19 @@ class AnalysisJobPlacer(Placer):
class GearPlacer(Placer):
def check(self):
pass
# self.requireTarget()
# validators.validate_data(self.metadata, 'file.json', 'input', 'POST', optional=True)
self.requireMetadata()
def process_file_field(self, field, file_attrs):
if self.metadata:
file_attrs.update(self.metadata)
self.metadata.update({'exchange': {'rootfs-hash': file_attrs.get('hash'),
proper_hash = file_attrs.get('hash')[3:].replace('-', ':')
self.metadata.update({'exchange': {'rootfs-hash': proper_hash,
'git-commit': 'local',
'rootfs-url': '/api/gears/temp/'+file_attrs.get('hash')}})
'rootfs-url': 'INVALID'}})
# self.metadata['hash'] = file_attrs.get('hash')
self.save_file(field)
self.saved.append(file_attrs)
self.saved.append(self.metadata)
def finalize(self):
return self.saved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment