From b39ff92f34e3fca389c78109d20d5454af761f8e Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 8 Mar 2023 22:27:13 +0000 Subject: [PATCH] u2cli: support long paths on win7 --- bin/up2k.py | 34 ++++++++++++++++++++++++++++++---- scripts/pyinstaller/build.sh | 2 ++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/bin/up2k.py b/bin/up2k.py index 80f5979e..9d6ecf7b 100755 --- a/bin/up2k.py +++ b/bin/up2k.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 from __future__ import print_function, unicode_literals -S_VERSION = "1.3" -S_BUILD_DT = "2023-03-05" +S_VERSION = "1.4" +S_BUILD_DT = "2023-03-08" """ up2k.py: upload to copyparty @@ -252,7 +252,13 @@ def eprint(*a, **ka): def flushing_print(*a, **ka): - _print(*a, **ka) + try: + _print(*a, **ka) + except: + v = " ".join(str(x) for x in a) + v = v.encode("ascii", "replace").decode("ascii") + _print(v, **ka) + if "flush" not in ka: sys.stdout.flush() @@ -379,6 +385,23 @@ def walkdir(err, top, seen): def walkdirs(err, tops): """recursive statdir for a list of tops, yields [top, relpath, stat]""" sep = "{0}".format(os.sep).encode("ascii") + if not VT100: + za = [] + for td in tops: + try: + ap = os.path.abspath(os.path.realpath(td)) + if td[-1:] in (b"\\", b"/"): + ap += sep + except: + # maybe cpython #88013 (ok) + ap = td + + za.append(ap) + + za = [x if x.startswith(b"\\\\") else b"\\\\?\\" + x for x in za] + za = [x.replace(b"/", b"\\") for x in za] + tops = za + for top in tops: isdir = os.path.isdir(top) if top[-1:] == sep: @@ -897,6 +920,9 @@ class Ctl(object): self.handshaker_busy += 1 upath = file.abs.decode("utf-8", "replace") + if not VT100: + upath = upath[4:] + hs, sprs = handshake(self.ar, file, search) if search: if hs: @@ -1066,7 +1092,7 @@ source file/folder selection uses rsync syntax, meaning that: ar.files = [ os.path.abspath(os.path.realpath(x.encode("utf-8"))) - + (x[-1:] if x[-1:] == os.sep else "").encode("utf-8") + + (x[-1:] if x[-1:] in ("\\", "/") else "").encode("utf-8") for x in ar.files ] diff --git a/scripts/pyinstaller/build.sh b/scripts/pyinstaller/build.sh index 2f5d9e5c..21904daa 100644 --- a/scripts/pyinstaller/build.sh +++ b/scripts/pyinstaller/build.sh @@ -59,6 +59,8 @@ read a b c d _ < <( sed -r 's/[^0-9]+//;s/[" )]//g;s/[-,]/ /g;s/$/ 0/' ) sed -r 's/1,2,3,0/'$a,$b,$c,$d'/;s/1\.2\.3/'$a.$b.$c/ loader.rc2 +[ $m ] && + sed -ri 's/copyparty.exe/copyparty32.exe/' loader.rc2 excl=( copyparty.broker_mp