소스 검색

HUE-2091 [fb] Configurable tempfile.tempdir for local file upload

Michalis Kongtongk 11 년 전
부모
커밋
9fe2102

+ 6 - 0
apps/filebrowser/src/filebrowser/conf.py

@@ -26,3 +26,9 @@ MAX_SNAPPY_DECOMPRESSION_SIZE = Config(
   private=True,
   default=1024*1024*25,
   type=int)
+
+ARCHIVE_UPLOAD_TEMPDIR = Config(
+  key="archive_upload_tempdir",
+  help=_("Location on local filesystem where the uploaded archives are temporary stored."),
+  default=None,
+  type=str)

+ 7 - 1
apps/filebrowser/src/filebrowser/lib/archives.py

@@ -23,6 +23,8 @@ import tarfile
 import tempfile
 from zipfile import ZipFile
 
+from filebrowser.conf import ARCHIVE_UPLOAD_TEMPDIR
+
 from django.utils.translation import ugettext as _
 
 
@@ -56,6 +58,7 @@ class ZipArchive(Archive):
   Acts on a zip file in memory or in a temporary location.
   Python's ZipFile class inherently buffers all reading.
   """
+
   def __init__(self, file):
     self.file = isinstance(file, basestring) and open(file) or file
     self.zfh = ZipFile(self.file)
@@ -67,7 +70,10 @@ class ZipArchive(Archive):
     Else, open a file for writing and meta pipe the contents zipfile to the new file.
     """
     # Store all extracted files in a temporary directory.
-    directory = tempfile.mkdtemp()
+    if ARCHIVE_UPLOAD_TEMPDIR.get():
+      directory = tempfile.mkdtemp(dir=ARCHIVE_UPLOAD_TEMPDIR.get())
+    else:
+      directory = tempfile.mkdtemp()
 
     dirs, files = self._filenames()
     self._create_dirs(directory, dirs)

+ 7 - 0
desktop/conf.dist/hue.ini

@@ -623,6 +623,13 @@
       # Enter the host on which you are running the failover JobTracker
       # jobtracker_host=localhost-ha
 
+###########################################################################
+# Settings to configure the Filebrowser app
+###########################################################################
+
+[filebrowser]
+  # Location on local filesystem where the uploaded archives are temporary stored.
+  ## archive_upload_tempdir=/tmp
 
 ###########################################################################
 # Settings to configure liboozie

+ 7 - 0
desktop/conf/pseudo-distributed.ini.tmpl

@@ -664,6 +664,13 @@
       # Enter the host on which you are running the failover JobTracker
       # jobtracker_host=localhost-ha
 
+###########################################################################
+# Settings to configure the Filebrowser app
+###########################################################################
+
+[filebrowser]
+  # Location on local filesystem where the uploaded archives are temporary stored.
+  ## archive_upload_tempdir=/tmp
 
 ###########################################################################
 # Settings to configure liboozie