mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-19 13:07:56 +00:00
Merge remote-tracking branch 'origin/master' into 3903.nix-flake.2
This commit is contained in:
commit
e7d98e69a1
0
newsfragments/4044.minor
Normal file
0
newsfragments/4044.minor
Normal file
@ -1030,14 +1030,14 @@ class _Client(node.Node, pollmixin.PollMixin):
|
||||
def init_web(self, webport):
|
||||
self.log("init_web(webport=%s)", args=(webport,))
|
||||
|
||||
from allmydata.webish import WebishServer, anonymous_tempfile
|
||||
from allmydata.webish import WebishServer, anonymous_tempfile_factory
|
||||
nodeurl_path = self.config.get_config_path("node.url")
|
||||
staticdir_config = self.config.get_config("node", "web.static", "public_html")
|
||||
staticdir = self.config.get_config_path(staticdir_config)
|
||||
ws = WebishServer(
|
||||
self,
|
||||
webport,
|
||||
anonymous_tempfile(self._get_tempdir()),
|
||||
anonymous_tempfile_factory(self._get_tempdir()),
|
||||
nodeurl_path,
|
||||
staticdir,
|
||||
)
|
||||
|
@ -341,7 +341,7 @@ class WebMixin(TimezoneMixin):
|
||||
self.ws = webish.WebishServer(
|
||||
self.s,
|
||||
"0",
|
||||
webish.anonymous_tempfile(tempdir.path),
|
||||
webish.anonymous_tempfile_factory(tempdir.path),
|
||||
staticdir=self.staticdir,
|
||||
clock=self.clock,
|
||||
now_fn=lambda:self.fakeTime,
|
||||
|
@ -6,9 +6,6 @@ import tempfile
|
||||
from uuid import (
|
||||
uuid4,
|
||||
)
|
||||
from errno import (
|
||||
EACCES,
|
||||
)
|
||||
from io import (
|
||||
BytesIO,
|
||||
)
|
||||
@ -30,9 +27,6 @@ from testtools.matchers import (
|
||||
HasLength,
|
||||
)
|
||||
|
||||
from twisted.python.runtime import (
|
||||
platform,
|
||||
)
|
||||
from twisted.python.filepath import (
|
||||
FilePath,
|
||||
)
|
||||
@ -50,7 +44,7 @@ from ..common import (
|
||||
from ...webish import (
|
||||
TahoeLAFSRequest,
|
||||
TahoeLAFSSite,
|
||||
anonymous_tempfile,
|
||||
anonymous_tempfile_factory,
|
||||
)
|
||||
|
||||
|
||||
@ -179,7 +173,7 @@ class TahoeLAFSSiteTests(SyncTestCase):
|
||||
FilePath(tempdir).makedirs()
|
||||
|
||||
site = TahoeLAFSSite(
|
||||
anonymous_tempfile(tempdir),
|
||||
anonymous_tempfile_factory(tempdir),
|
||||
Resource(),
|
||||
logPath=logPath,
|
||||
)
|
||||
|
@ -4,7 +4,7 @@ General web server-related utilities.
|
||||
from __future__ import annotations
|
||||
|
||||
from six import ensure_str
|
||||
from typing import BinaryIO, Callable, Optional
|
||||
from typing import IO, Callable, Optional
|
||||
import re, time, tempfile
|
||||
from urllib.parse import parse_qsl, urlencode
|
||||
|
||||
@ -217,7 +217,7 @@ def censor(queryargs: bytes) -> bytes:
|
||||
return urlencode(result, safe="[]").encode("ascii")
|
||||
|
||||
|
||||
def anonymous_tempfile(tempdir: bytes) -> BinaryIO:
|
||||
def anonymous_tempfile_factory(tempdir: bytes) -> Callable[[], IO[bytes]]:
|
||||
"""
|
||||
Create a no-argument callable for creating a new temporary file in the
|
||||
given directory.
|
||||
@ -243,14 +243,14 @@ class TahoeLAFSSite(Site, object):
|
||||
"""
|
||||
requestFactory = TahoeLAFSRequest
|
||||
|
||||
def __init__(self, make_tempfile: Callable[[], BinaryIO], *args, **kwargs):
|
||||
def __init__(self, make_tempfile: Callable[[], IO[bytes]], *args, **kwargs):
|
||||
Site.__init__(self, *args, logFormatter=_logFormatter, **kwargs)
|
||||
assert callable(make_tempfile)
|
||||
with make_tempfile():
|
||||
pass
|
||||
self._make_tempfile = make_tempfile
|
||||
|
||||
def getContentFile(self, length: Optional[int]) -> BinaryIO:
|
||||
def getContentFile(self, length: Optional[int]) -> IO[bytes]:
|
||||
if length is None or length >= 1024 * 1024:
|
||||
return self._make_tempfile()
|
||||
return BytesIO()
|
||||
|
Loading…
Reference in New Issue
Block a user