Change build logs load to using streaming Gzip
This commit is contained in:
parent
57336b32e6
commit
c0c1da3232
2 changed files with 116 additions and 6 deletions
|
@ -1,8 +1,7 @@
|
|||
import logging
|
||||
|
||||
from gzip import GzipFile
|
||||
from util.registry.gzipinputstream import GzipInputStream
|
||||
from flask import send_file, abort
|
||||
from cStringIO import StringIO
|
||||
|
||||
from data.userfiles import DelegateUserfiles, UserfilesHandlers
|
||||
|
||||
|
@ -17,10 +16,8 @@ class LogArchiveHandlers(UserfilesHandlers):
|
|||
def get(self, file_id):
|
||||
path = self._files.get_file_id_path(file_id)
|
||||
try:
|
||||
with self._storage.stream_read_file(self._locations, path) as gzip_stream:
|
||||
with GzipFile(fileobj=gzip_stream) as unzipped:
|
||||
unzipped_buffer = StringIO(unzipped.read())
|
||||
return send_file(unzipped_buffer, mimetype=JSON_MIMETYPE)
|
||||
data_stream = self._storage.stream_read_file(self._locations, path)
|
||||
return send_file(GzipInputStream(data_stream), mimetype=JSON_MIMETYPE)
|
||||
except IOError:
|
||||
abort(404)
|
||||
|
||||
|
|
Reference in a new issue