From e00f2b46eb41e074ea82014b04f67d83a4ecf0aa Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 16 Apr 2026 10:01:22 +0000 Subject: [PATCH] webdav: allow propfind depth:inf on files (closes #1437); some webdav-clients (webdav4) sends Depth: infinite also for files, assume Depth: 0 in this case --- copyparty/httpcli.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 06ea6190..79186d42 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -1800,7 +1800,11 @@ class HttpCli(object): topdir = {"vp": "", "st": st} fgen: Iterable[dict[str, Any]] = [] - depth = self.headers.get("depth", "infinity").lower() + if stat.S_ISDIR(st.st_mode): + depth = self.headers.get("depth", "infinity").lower() + else: + depth = "0" + if depth == "infinity": # allow depth:0 from unmapped root, but require read-axs otherwise if not self.can_read and (self.vpath or self.asrv.vfs.realpath): @@ -1809,12 +1813,6 @@ class HttpCli(object): self.log(t, 3) raise Pebkac(401, t) - if not stat.S_ISDIR(topdir["st"].st_mode): - t = "depth:infinity can only be used on folders; %r is 0o%o" - t = t % ("/" + self.vpath, topdir["st"]) - self.log(t, 3) - raise Pebkac(400, t) - if not self.args.dav_inf: self.log("client wants --dav-inf", 3) zb = b'\n' @@ -1835,7 +1833,7 @@ class HttpCli(object): wrap=False, ) - elif depth == "0" or not stat.S_ISDIR(st.st_mode): + elif depth == "0": if depth == "0" and not self.vpath and not vn.realpath: # rootless server; give dummy listing self.can_read = True