From: Brian Warner Date: Thu, 15 Jan 2009 03:00:15 +0000 (-0700) Subject: node.py: use NODEDIR/tmp for the 'tempfile' module's temporary directory, so webapi... X-Git-Tag: allmydata-tahoe-1.3.0~189 X-Git-Url: https://git.rkrishnan.org/pf/content/simplejson/provisioning?a=commitdiff_plain;h=26ca53fa3db534e04070f451040b9383b023416d;p=tahoe-lafs%2Ftahoe-lafs.git node.py: use NODEDIR/tmp for the 'tempfile' module's temporary directory, so webapi upload tempfiles are put there instead of /tmp . You can set it to something else by setting [node]tempdir in tahoe.cfg --- diff --git a/docs/configuration.txt b/docs/configuration.txt index bb53bee8..6df08624 100644 --- a/docs/configuration.txt +++ b/docs/configuration.txt @@ -205,6 +205,18 @@ ssh.authorized_keys_file = (filename, optional) ssh.port = 8022 ssh.authorized_keys_file = ~/.ssh/authorized_keys +tempdir = (string, optional) + + This specifies a temporary directory for the webapi server to use, for + holding large files while they are being uploaded. If a webapi client + attempts to upload a 10GB file, this tempdir will need to have at least 10GB + available for the upload to complete. + + The default value is the "tmp" directory in the node's base directory (i.e. + $NODEDIR/tmp), but it can be placed elsewhere. This directory is used for + files that usually (on a unix system) go into /tmp . The string will be + interpreted relative to the node's base directory. + == Client Configuration == [client] diff --git a/src/allmydata/node.py b/src/allmydata/node.py index da4b860c..e9dd3b7e 100644 --- a/src/allmydata/node.py +++ b/src/allmydata/node.py @@ -1,5 +1,5 @@ -import datetime, os.path, re, types, ConfigParser +import datetime, os.path, re, types, ConfigParser, tempfile from base64 import b32decode, b32encode from twisted.python import log as twlog @@ -10,7 +10,7 @@ import foolscap.logging.log from allmydata import get_package_versions, get_package_versions_string from allmydata.util import log from allmydata.util import fileutil, iputil, observer -from allmydata.util.assertutil import precondition +from allmydata.util.assertutil import precondition, _assert from foolscap.logging import app_versions @@ -65,6 +65,7 @@ class Node(service.MultiService): nickname_utf8 = self.get_config("node", "nickname", "") self.nickname = nickname_utf8.decode("utf-8") + self.init_tempdir() self.create_tub() self.logSource="Node" @@ -73,6 +74,20 @@ class Node(service.MultiService): self.log("Node constructed. " + get_package_versions_string()) iputil.increase_rlimits() + def init_tempdir(self): + local_tempdir = "tmp" # default is NODEDIR/tmp/ + tempdir = self.get_config("node", "tempdir", local_tempdir) + tempdir = os.path.join(self.basedir, tempdir) + if not os.path.exists(tempdir): + fileutil.make_dirs(tempdir) + tempfile.tempdir = os.path.abspath(tempdir) + # this should cause twisted.web.http (which uses + # tempfile.TemporaryFile) to put large request bodies in the given + # directory. Without this, the default temp dir is usually /tmp/, + # which is frequently too small. + test_name = tempfile.mktemp() + _assert(os.path.dirname(test_name) == tempdir, test_name, tempdir) + def get_config(self, section, option, default=_None, boolean=False): try: if boolean: