Get rid of the tempfile.tempdir hackery

This commit is contained in:
Jean-Paul Calderone 2020-11-18 15:51:08 -05:00
parent 46955202e2
commit 6d137ac257

View File

@ -740,8 +740,6 @@ class Node(service.MultiService):
self._i2p_provider = i2p_provider
self._tor_provider = tor_provider
self.init_tempdir()
self.create_log_tub()
self.logSource = "Node"
self.setup_logging()
@ -768,25 +766,6 @@ class Node(service.MultiService):
"""
return len(self.tub.getListeners()) > 0
def init_tempdir(self):
"""
Initialize/create a directory for temporary files.
"""
tempdir_config = self.config.get_config("node", "tempdir", "tmp")
if isinstance(tempdir_config, bytes):
tempdir_config = tempdir_config.decode('utf-8')
tempdir = self.config.get_config_path(tempdir_config)
if not os.path.exists(tempdir):
fileutil.make_dirs(tempdir)
tempfile.tempdir = 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.
temp_fd, test_name = tempfile.mkstemp()
_assert(os.path.dirname(test_name) == tempdir, test_name, tempdir)
os.close(temp_fd) # avoid leak of unneeded fd
# pull this outside of Node's __init__ too, see:
# https://tahoe-lafs.org/trac/tahoe-lafs/ticket/2948
def create_log_tub(self):