Add a mime type for x-zip-compressed. Report unknown mime types as errors.

This commit is contained in:
jakedt 2014-03-06 23:40:21 -05:00
parent d12a53186a
commit 4566d76e45

View file

@ -248,6 +248,7 @@ class DockerfileBuildWorker(Worker):
self._mime_processors = {
'application/zip': DockerfileBuildWorker.__prepare_zip,
'application/x-zip-compressed': DockerfileBuildWorker.__prepare_zip,
'text/plain': DockerfileBuildWorker.__prepare_dockerfile,
'application/octet-stream': DockerfileBuildWorker.__prepare_dockerfile,
}
@ -305,7 +306,11 @@ class DockerfileBuildWorker(Worker):
log_appender(filetype_msg)
if c_type not in self._mime_processors:
raise RuntimeError('Invalid dockerfile content type: %s' % c_type)
log_appender('error', build_logs.PHASE)
repository_build.phase = 'error'
repository_build.save()
log_appender('Unknown mime-type: %s' % c_type, build_logs.ERROR)
return True
build_dir = self._mime_processors[c_type](docker_resource)
log_appender('building', build_logs.PHASE)