From 9ebf148cbea50f2903d6d83c994e92c0080c779d Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 27 Jun 2022 22:15:35 +0200 Subject: [PATCH] support android9 sdcardfs on sdcard --- copyparty/util.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/copyparty/util.py b/copyparty/util.py index 1177fb5c..a3c79d2f 100644 --- a/copyparty/util.py +++ b/copyparty/util.py @@ -589,6 +589,7 @@ def ren_open( ext = bname[ofs:] + ext bname = bname[:ofs] + asciified = False b64 = "" while True: try: @@ -614,11 +615,20 @@ def ren_open( except OSError as ex_: ex = ex_ + + if ex.errno == 22 and not asciified: + asciified = True + bname, fname = [ + zs.encode("ascii", "replace").decode("ascii").replace("?", "_") + for zs in [bname, fname] + ] + continue + if ex.errno not in [36, 63] and (not WINDOWS or ex.errno != 22): raise if not b64: - zs = (bname + ext).encode("utf-8", "replace") + zs = (orig_name + "\n" + suffix).encode("utf-8", "replace") zs = hashlib.sha512(zs).digest()[:12] b64 = base64.urlsafe_b64encode(zs).decode("utf-8")