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 # coding: utf-8
VERSION = (0, 6, 1) VERSION = (0, 6, 2)
CODENAME = "CHRISTMAAAAAS" CODENAME = "CHRISTMAAAAAS"
BUILD_DT = (2020, 12, 14) BUILD_DT = (2020, 12, 14)

View file

@ -583,7 +583,7 @@ class HttpCli(object):
fdir = "" fdir = ""
try: 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"] f, fname = f["orz"]
self.log("writing to {}/{}".format(fdir, fname)) self.log("writing to {}/{}".format(fdir, fname))
sz, sha512_hex, _ = hashcopy(self.conn, p_data, f) sz, sha512_hex, _ = hashcopy(self.conn, p_data, f)
@ -737,7 +737,7 @@ class HttpCli(object):
if p_field != "body": if p_field != "body":
raise Pebkac(400, "expected body, got {}".format(p_field)) 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) sz, sha512, _ = hashcopy(self.conn, p_data, f)
new_lastmod = os.stat(fsenc(fp)).st_mtime new_lastmod = os.stat(fsenc(fp)).st_mtime

View file

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