diff options
Diffstat (limited to 'kbas/__main__.py')
-rwxr-xr-x | kbas/__main__.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/kbas/__main__.py b/kbas/__main__.py index 7629710..80de7ef 100755 --- a/kbas/__main__.py +++ b/kbas/__main__.py @@ -23,7 +23,7 @@ from time import strftime, gmtime from datetime import datetime import tempfile from bottle import Bottle, request, response, template, static_file -from subprocess import call +from subprocess import call, check_output from ybd import app, cache @@ -152,7 +152,13 @@ class KeyedBinaryArtifactServer(object): with open(artifact, "w") as f: f.write(upload.value) - if call(['tar', 'tf', artifact]): + if artifact.endswith('.rpm'): + ftype = check_output( + ['file', '--brief', '--mime-type', artifact]).strip() + if ftype != "application/x-rpm": + app.log('UPLOAD', 'ERROR: not a valid rpm:', artifact) + raise TypeError("Not a valid rpm") + elif call(['tar', 'tf', artifact]): app.log('UPLOAD', 'ERROR: not a valid tarfile:', artifact) raise checksum = cache.md5(artifact) |