diff --git a/copyparty/authsrv.py b/copyparty/authsrv.py index 69bfc3f9..0f5cc6c5 100644 --- a/copyparty/authsrv.py +++ b/copyparty/authsrv.py @@ -10,7 +10,7 @@ import hashlib import threading from .__init__ import WINDOWS -from .util import IMPLICATIONS, undot, Pebkac, fsdec, fsenc, statdir, nuprint +from .util import IMPLICATIONS, uncyg, undot, Pebkac, fsdec, fsenc, statdir, nuprint class VFS(object): @@ -439,8 +439,8 @@ class AuthSrv(object): raise Exception("invalid -v argument: [{}]".format(v_str)) src, dst, perms = m.groups() - if WINDOWS and src.startswith("/"): - src = "{}:\\{}".format(src[1], src[3:]) + if WINDOWS: + src = uncyg(src) # print("\n".join([src, dst, perms])) src = fsdec(os.path.abspath(fsenc(src))) @@ -524,9 +524,7 @@ class AuthSrv(object): if vflag == "-": pass elif vflag: - if WINDOWS and vflag.startswith("/"): - vflag = "{}:\\{}".format(vflag[1], vflag[3:]) - vol.histpath = vflag + vol.histpath = uncyg(vflag) if WINDOWS else vflag elif self.args.hist: for nch in range(len(hid)): hpath = os.path.join(self.args.hist, hid[: nch + 1]) diff --git a/copyparty/mtag.py b/copyparty/mtag.py index daf3a233..f76a17eb 100644 --- a/copyparty/mtag.py +++ b/copyparty/mtag.py @@ -8,7 +8,7 @@ import shutil import subprocess as sp from .__init__ import PY2, WINDOWS -from .util import fsenc, fsdec, REKOBO_LKEY +from .util import fsenc, fsdec, uncyg, REKOBO_LKEY if not PY2: unicode = str @@ -44,6 +44,9 @@ class MParser(object): while True: try: bp = os.path.expanduser(args) + if WINDOWS: + bp = uncyg(bp) + if os.path.exists(bp): self.bin = bp return diff --git a/copyparty/util.py b/copyparty/util.py index d7efb9dc..c4a1ae68 100644 --- a/copyparty/util.py +++ b/copyparty/util.py @@ -648,6 +648,16 @@ def s2hms(s, optional_h=False): return "{}:{:02}:{:02}".format(h, m, s) +def uncyg(path): + if not path.startswith("/"): + return path + + if len(path) < 3 and path[2] != "/": + return path + + return "{}:\\{}".format(path[1], path[3:]) + + def undot(path): ret = [] for node in path.split("/"):