summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xkbas/__main__.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/kbas/__main__.py b/kbas/__main__.py
index 926068d..6a7e1fb 100755
--- a/kbas/__main__.py
+++ b/kbas/__main__.py
@@ -117,14 +117,20 @@ class KeyedBinaryArtifactServer(object):
tmpdir = tempfile.mkdtemp()
try:
upload = request.files.get('file')
- upload.save(os.path.join(tmpdir, cache_id))
+ artifact = os.path.join(tmpdir, cache_id)
+ upload.save(artifact)
+ unpackdir = artifact + '.unpacked'
+ if call(['tar', 'xf', artifact, '--directory', unpackdir]):
+ app.log(this, 'ERROR: Problem unpacking', artifact)
+ raise
+ shutil.rmtree(unpackdir)
os.rename(tmpdir, os.path.join(app.config['artifact-dir'], cache_id))
response.status = 201 # success!
return
except:
- # this was a race, remove the tmpdir
+ # something went wrong, clean up
shutil.rmtree(tmpdir)
- response.status = 999 # method not allowed, this artifact exists
+ response.status = 999
return