Skip to content

Commit

Permalink
fix v1.16.0 webdav upload regression; closes #119
Browse files Browse the repository at this point in the history
  • Loading branch information
9001 committed Nov 23, 2024
1 parent b10843d commit 7dfbfc7
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions copyparty/httpcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand All @@ -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 ""
Expand Down

0 comments on commit 7dfbfc7

Please sign in to comment.