diff --git a/copyparty/__version__.py b/copyparty/__version__.py index c67474ac..4be8d44f 100644 --- a/copyparty/__version__.py +++ b/copyparty/__version__.py @@ -1,6 +1,6 @@ # coding: utf-8 -VERSION = (0, 6, 1) +VERSION = (0, 6, 2) CODENAME = "CHRISTMAAAAAS" BUILD_DT = (2020, 12, 14) diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 248901a4..a3c01e40 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -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 diff --git a/copyparty/util.py b/copyparty/util.py index f735a55b..b0d84077 100644 --- a/copyparty/util.py +++ b/copyparty/util.py @@ -99,12 +99,15 @@ 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 - + orig_name = fname bname = fname ext = ""