fix windows symlink creation

This commit is contained in:
ed 2022-09-17 13:27:54 +02:00
parent 415e61c3c9
commit 5e9bc1127d
2 changed files with 8 additions and 8 deletions

View file

@ -749,7 +749,7 @@ def run_argparse(argv: list[str], formatter: Any, retry: bool) -> argparse.Names
ap2.add_argument("--no-scandir", action="store_true", help="disable scandir; instead using listdir + stat on each file")
ap2.add_argument("--no-fastboot", action="store_true", help="wait for up2k indexing before starting the httpd")
ap2.add_argument("--no-htp", action="store_true", help="disable httpserver threadpool, create threads as-needed instead")
ap2.add_argument("--stackmon", metavar="P,S", type=u, help="write stacktrace to Path every S second, for example --stackmon=./st/%Y-%m/%d/%H%M.xz,60")
ap2.add_argument("--stackmon", metavar="P,S", type=u, help="write stacktrace to Path every S second, for example --stackmon=./st/%%Y-%%m/%%d/%%H%%M.xz,60")
ap2.add_argument("--log-thrs", metavar="SEC", type=float, help="list active threads every SEC")
ap2.add_argument("--log-fk", metavar="REGEX", type=u, default="", help="log filekey params for files where path matches REGEX; '.' (a single dot) = all files")
# fmt: on

View file

@ -2133,13 +2133,9 @@ class Up2k(object):
raise OSError(38, "filesystem does not have st_dev")
elif fs1 == fs2:
# same fs; make symlink as relative as possible
v = []
for p in [src, dst]:
if WINDOWS:
p = p.replace("\\", "/")
v.append(p.split("/"))
nsrc, ndst = v
spl = r"[\\/]" if WINDOWS else "/"
nsrc = re.split(spl, src)
ndst = re.split(spl, dst)
nc = 0
for a, b in zip(nsrc, ndst):
if a != b:
@ -2150,6 +2146,10 @@ class Up2k(object):
hops = len(ndst[nc:]) - 1
lsrc = "../" * hops + "/".join(zsl)
if WINDOWS:
lsrc = lsrc.replace("/", "\\")
ldst = ldst.replace("/", "\\")
try:
if self.args.hardlink:
os.link(fsenc(src), fsenc(dst))