From 806fac174292df63889ac408a608969c847a5c7f Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 19 Oct 2021 00:58:24 +0200 Subject: [PATCH] nullwrite fixes --- copyparty/httpcli.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 1af62ca4..22f0262f 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -545,9 +545,8 @@ class HttpCli(object): bos.makedirs(fdir) - open_f = open + open_ka = {"fun": open} open_a = ["wb", 512 * 1024] - open_ka = {} # user-request || config-force if ("gz" in vfs.flags or "xz" in vfs.flags) and ( @@ -588,28 +587,24 @@ class HttpCli(object): self.log("compressing with {} level {}".format(alg, lv.get(alg))) if alg == "gz": - open_f = gzip.GzipFile + open_ka["fun"] = gzip.GzipFile open_a = ["wb", lv[alg], None, 0x5FEE6600] # 2021-01-01 elif alg == "xz": - open_f = lzma.open + open_ka = {"fun": lzma.open, "preset": lv[alg]} open_a = ["wb"] - open_ka = {"preset": lv[alg]} else: self.log("fallthrough? thats a bug", 1) - params = { - "suffix": "-{:.6f}-{}".format(time.time(), self.dip), - "fdir": fdir, - "fun": open_f, - } - params.update(open_ka) - + suffix = "-{:.6f}-{}".format(time.time(), self.dip) + params = {"suffix": suffix, "fdir": fdir} if self.args.nw: params = {} fn = os.devnull + params.update(open_ka) + if not fn: - fn = "put" + params["suffix"] + fn = "put" + suffix with ren_open(fn, *open_a, **params) as f: f, fn = f["orz"]