From 7dfbfc7227d7c751cba9c522c3c3d1b547d63a3d Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 23 Nov 2024 23:32:56 +0000 Subject: [PATCH] fix v1.16.0 webdav upload regression; closes #119 --- copyparty/httpcli.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 8c3e162a..76f8883a 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -704,7 +704,7 @@ def run(self) -> bool: if pex.code != 404 or self.do_log: self.log( - "%s\033[0m, %s" % (msg, self.vpath), + "http%d: %s\033[0m, %s" % (pex.code, msg, self.vpath), 6 if em.startswith("client d/c ") else 3, ) @@ -1413,12 +1413,13 @@ def handle_propfind(self) -> bool: vst = os.stat_result((16877, -1, -1, 1, 1000, 1000, 8, zi, zi, zi)) try: - topdir = {"vp": "", "st": bos.stat(tap)} + st = bos.stat(tap) except OSError as ex: if ex.errno not in (errno.ENOENT, errno.ENOTDIR): raise raise Pebkac(404) + topdir = {"vp": "", "st": st} fgen: Iterable[dict[str, Any]] = [] depth = self.headers.get("depth", "infinity").lower() @@ -1454,6 +1455,12 @@ def handle_propfind(self) -> bool: wrap=False, ) + elif depth == "0" or not stat.S_ISDIR(st.st_mode): + # propfind on a file; return as topdir + if not self.can_read and not self.can_get: + self.log("inaccessible: [%s]" % (self.vpath,)) + raise Pebkac(401, "authenticate") + elif depth == "1": _, vfs_ls, vfs_virt = vn.ls( rem, @@ -1472,9 +1479,6 @@ def handle_propfind(self) -> bool: fgen = [{"vp": vp, "st": st} for vp, st in vfs_ls] fgen += [{"vp": v, "st": vst} for v in vfs_virt] - elif depth == "0": - pass - else: t = "invalid depth value '{}' (must be either '0' or '1'{})" t2 = " or 'infinity'" if self.args.dav_inf else ""