Explorar el Código

HUE-7539 [filebrowser] fixing downloading a file hangs the full Hue.
We have done some performance analysis and found out that 1MB buffer size works best.

Prakash Ranade hace 8 años
padre
commit
657c4ef3df
Se han modificado 1 ficheros con 3 adiciones y 3 borrados
  1. 3 3
      apps/filebrowser/src/filebrowser/views.py

+ 3 - 3
apps/filebrowser/src/filebrowser/views.py

@@ -37,7 +37,7 @@ from django.contrib.auth.models import User, Group
 from django.core.paginator import EmptyPage
 from django.core.paginator import EmptyPage
 from django.core.urlresolvers import reverse
 from django.core.urlresolvers import reverse
 from django.template.defaultfilters import stringformat, filesizeformat
 from django.template.defaultfilters import stringformat, filesizeformat
-from django.http import Http404, HttpResponse, HttpResponseNotModified, HttpResponseForbidden
+from django.http import Http404, StreamingHttpResponse, HttpResponseNotModified, HttpResponseForbidden
 from django.views.decorators.http import require_http_methods
 from django.views.decorators.http import require_http_methods
 from django.views.static import was_modified_since
 from django.views.static import was_modified_since
 from django.shortcuts import redirect
 from django.shortcuts import redirect
@@ -77,7 +77,7 @@ from filebrowser.forms import RenameForm, UploadFileForm, UploadArchiveForm, MkD
 
 
 DEFAULT_CHUNK_SIZE_BYTES = 1024 * 4 # 4KB
 DEFAULT_CHUNK_SIZE_BYTES = 1024 * 4 # 4KB
 MAX_CHUNK_SIZE_BYTES = 1024 * 1024 # 1MB
 MAX_CHUNK_SIZE_BYTES = 1024 * 1024 # 1MB
-DOWNLOAD_CHUNK_SIZE = 64 * 1024 * 1024 # 64MB
+DOWNLOAD_CHUNK_SIZE = 1 * 1024 * 1024 # 1MB
 
 
 # Defaults for "xxd"-style output.
 # Defaults for "xxd"-style output.
 # Sentences refer to groups of bytes printed together, within a line.
 # Sentences refer to groups of bytes printed together, within a line.
@@ -161,7 +161,7 @@ def download(request, path):
         else:
         else:
             raise PopupException(_('Failed to download file at path "%s": %s') % (path, e))
             raise PopupException(_('Failed to download file at path "%s": %s') % (path, e))
 
 
-    response = HttpResponse(_file_reader(fh), content_type=content_type)
+    response = StreamingHttpResponse(_file_reader(fh), content_type=content_type)
     response["Last-Modified"] = http_date(stats['mtime'])
     response["Last-Modified"] = http_date(stats['mtime'])
     response["Content-Length"] = stats['size']
     response["Content-Length"] = stats['size']
     response['Content-Disposition'] = request.GET.get('disposition', 'attachment') if _can_inline_display(path) else 'attachment'
     response['Content-Disposition'] = request.GET.get('disposition', 'attachment') if _can_inline_display(path) else 'attachment'