diff --git a/copyparty/authsrv.py b/copyparty/authsrv.py index 136683bd..6ba44390 100644 --- a/copyparty/authsrv.py +++ b/copyparty/authsrv.py @@ -447,11 +447,20 @@ class VFS(object): def canonical(self, rem: str, resolve: bool = True) -> str: """returns the canonical path (fully-resolved absolute fs path)""" - rp = self.realpath + ap = self.realpath if rem: - rp += "/" + rem + ap += "/" + rem - return absreal(rp) if resolve else rp + return absreal(ap) if resolve else ap + + def dcanonical(self, rem: str) -> str: + """resolves until the final component (filename)""" + ap = self.realpath + if rem: + ap += "/" + rem + + ad, fn = os.path.split(ap) + return os.path.join(absreal(ad), fn) def ls( self, diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 791dcaee..15c815da 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -2491,7 +2491,7 @@ class HttpCli(object): vpnodes.append([quotep(vpath) + "/", html_escape(node, crlf=True)]) vn, rem = self.asrv.vfs.get(self.vpath, self.uname, False, False) - abspath = vn.canonical(rem) + abspath = vn.dcanonical(rem) dbv, vrem = vn.get_dbv(rem) try: diff --git a/copyparty/util.py b/copyparty/util.py index c2d981d2..574949ff 100644 --- a/copyparty/util.py +++ b/copyparty/util.py @@ -1330,8 +1330,24 @@ def gen_filekey_dbg( assert log_ptn if log_ptn.search(fspath): - t = "fk({}) salt({}) size({}) inode({}) fspath({})" - log(t.format(ret[:8], salt, fsize, inode, fspath)) + try: + import inspect + + ctx = ",".join(inspect.stack()[n][3] for n in range(2, 5)) + except: + ctx = "" + + try: + p2 = "a" + p2 = absreal(fspath) + if p2 != fspath: + raise Exception() + except: + t = "maybe wrong abspath for filekey;\norig: {}\nreal: {}" + log(t.format(fspath, p2), 1) + + t = "fk({}) salt({}) size({}) inode({}) fspath({}) at({})" + log(t.format(ret[:8], salt, fsize, inode, fspath, ctx), 5) return ret