diff options
author | Elliot Smith <elliot.smith@intel.com> | 2015-12-18 11:55:25 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-12-18 13:52:00 +0000 |
commit | 6e3eefb997063971801bea933f319bb428b33fa5 (patch) | |
tree | 9d27aebef3a0d686c401e772024e18e431a1e4b3 /bitbake/lib/toaster/toastergui | |
parent | aff2257e0b1153814aefc96737e00bdb4cf634e0 (diff) | |
download | poky-6e3eefb997063971801bea933f319bb428b33fa5.tar.gz |
bitbake: toaster: Rework mimetype guessing to fix artifact downloads
Artifact download links were broken because the function to
get the mimetype for the artifact was incorrectly using the
underlying mimetype library. The function was also attached
to the build environment controller, which was unnecessary, as
we only support local controllers anyway.
Remove the mimetype getter on the build environment and
use the one in the view code instead. This prevents the download error
from occurring.
(Backport of dd957fe0f261db6481882fee0413f459425000c2 and
dd957fe0f261db6481882fee0413f459425000c2 from master to Yocto 1.8)
[YOCTO #8472]
(Bitbake rev: b09966906ef054834f0b465f0c5a2a937b4c4a4c)
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui')
-rwxr-xr-x | bitbake/lib/toaster/toastergui/views.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index be59c83651..98b040e5ab 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py | |||
@@ -39,6 +39,22 @@ from datetime import timedelta, datetime, date | |||
39 | from django.utils import formats | 39 | from django.utils import formats |
40 | from toastergui.templatetags.projecttags import json as jsonfilter | 40 | from toastergui.templatetags.projecttags import json as jsonfilter |
41 | import json | 41 | import json |
42 | import mimetypes | ||
43 | |||
44 | class MimeTypeFinder(object): | ||
45 | # setting this to False enables additional non-standard mimetypes | ||
46 | # to be included in the guess | ||
47 | _strict = False | ||
48 | |||
49 | # returns the mimetype for a file path as a string, | ||
50 | # or 'application/octet-stream' if the type couldn't be guessed | ||
51 | @classmethod | ||
52 | def get_mimetype(self, path): | ||
53 | guess = mimetypes.guess_type(path, self._strict) | ||
54 | guessed_type = guess[0] | ||
55 | if guessed_type == None: | ||
56 | guessed_type = 'application/octet-stream' | ||
57 | return guessed_type | ||
42 | 58 | ||
43 | # all new sessions should come through the landing page; | 59 | # all new sessions should come through the landing page; |
44 | # determine in which mode we are running in, and redirect appropriately | 60 | # determine in which mode we are running in, and redirect appropriately |
@@ -3209,7 +3225,7 @@ if toastermain.settings.MANAGED: | |||
3209 | if file_name is None: | 3225 | if file_name is None: |
3210 | raise Exception("Could not handle artifact %s id %s" % (artifact_type, artifact_id)) | 3226 | raise Exception("Could not handle artifact %s id %s" % (artifact_type, artifact_id)) |
3211 | else: | 3227 | else: |
3212 | content_type = b.buildrequest.environment.get_artifact_type(file_name) | 3228 | content_type = MimeTypeFinder.get_mimetype(file_name) |
3213 | fsock = b.buildrequest.environment.get_artifact(file_name) | 3229 | fsock = b.buildrequest.environment.get_artifact(file_name) |
3214 | file_name = os.path.basename(file_name) # we assume that the build environment system has the same path conventions as host | 3230 | file_name = os.path.basename(file_name) # we assume that the build environment system has the same path conventions as host |
3215 | 3231 | ||