This commit is contained in:
ed 2020-12-14 04:28:21 +01:00
parent d08245c3df
commit ba94cc5df7
3 changed files with 9 additions and 6 deletions

View file

@ -1,6 +1,6 @@
# coding: utf-8
VERSION = (0, 6, 1)
VERSION = (0, 6, 2)
CODENAME = "CHRISTMAAAAAS"
BUILD_DT = (2020, 12, 14)

View file

@ -583,7 +583,7 @@ class HttpCli(object):
fdir = ""
try:
with ren_open(fname, "wb", **open_args) as f:
with ren_open(fname, "wb", 512 * 1024, **open_args) as f:
f, fname = f["orz"]
self.log("writing to {}/{}".format(fdir, fname))
sz, sha512_hex, _ = hashcopy(self.conn, p_data, f)
@ -737,7 +737,7 @@ class HttpCli(object):
if p_field != "body":
raise Pebkac(400, "expected body, got {}".format(p_field))
with open(fp, "wb") as f:
with open(fp, "wb", 512 * 1024) as f:
sz, sha512, _ = hashcopy(self.conn, p_data, f)
new_lastmod = os.stat(fsenc(fp)).st_mtime

View file

@ -99,8 +99,11 @@ class Unrecv(object):
@contextlib.contextmanager
def ren_open(fname, *args, fdir=None, suffix=None, **kwargs):
if hasattr(fname, "write"):
def ren_open(fname, *args, **kwargs):
fdir = kwargs.pop("fdir", None)
suffix = kwargs.pop("suffix", None)
if fname == os.devnull:
with open(fname, *args, **kwargs) as f:
yield {"orz": [f, fname]}
return