diff --git a/bin/up2k.py b/bin/up2k.py index 010d094d..bdba5134 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.6" -S_BUILD_DT = "2023-04-20" +S_VERSION = "1.7" +S_BUILD_DT = "2023-04-26" """ up2k.py: upload to copyparty @@ -344,13 +344,13 @@ def undns(url): usp = urlsplit(url) hn = usp.hostname gai = None - print("resolving host [{0}] ...".format(hn), end="") + eprint("resolving host [{0}] ...".format(hn), end="") try: gai = socket.getaddrinfo(hn, None) hn = gai[0][4][0] except: t = "\n\033[31mfailed to resolve upload destination host;\033[0m\ngai={0}\n" - print(t.format(repr(gai))) + eprint(t.format(repr(gai))) raise if usp.port: @@ -360,7 +360,7 @@ def undns(url): usp = usp._replace(netloc=hn) url = urlunsplit(usp) - print(" {0}".format(url)) + eprint(" {0}".format(url)) return url @@ -1100,6 +1100,7 @@ source file/folder selection uses rsync syntax, meaning that: ap = app.add_argument_group("compatibility") ap.add_argument("--cls", action="store_true", help="clear screen before start") + ap.add_argument("--rh", action="store_true", help="resolve server hostname before upload (good for buggy networks, but TLS certs will break)") ap = app.add_argument_group("folder sync") ap.add_argument("--dl", action="store_true", help="delete local files after uploading") @@ -1123,7 +1124,7 @@ source file/folder selection uses rsync syntax, meaning that: ar = app.parse_args() finally: if EXE and not sys.argv[1:]: - print("*** hit enter to exit ***") + eprint("*** hit enter to exit ***") try: input() except: @@ -1156,11 +1157,11 @@ source file/folder selection uses rsync syntax, meaning that: with open(fn, "rb") as f: ar.a = f.read().decode("utf-8").strip() - # resolve hostname (good on buggy networks) - ar.url = undns(ar.url) + if ar.rh: + ar.url = undns(ar.url) if ar.cls: - print("\x1b\x5b\x48\x1b\x5b\x32\x4a\x1b\x5b\x33\x4a", end="") + eprint("\x1b\x5b\x48\x1b\x5b\x32\x4a\x1b\x5b\x33\x4a", end="") ctl = Ctl(ar) diff --git a/copyparty/__version__.py b/copyparty/__version__.py index f1719ff3..2d126a7b 100644 --- a/copyparty/__version__.py +++ b/copyparty/__version__.py @@ -1,8 +1,8 @@ # coding: utf-8 -VERSION = (1, 6, 14) +VERSION = (1, 6, 15) CODENAME = "cors k" -BUILD_DT = (2023, 4, 24) +BUILD_DT = (2023, 4, 26) S_VERSION = ".".join(map(str, VERSION)) S_BUILD_DT = "{0:04d}-{1:02d}-{2:02d}".format(*BUILD_DT) diff --git a/copyparty/ftpd.py b/copyparty/ftpd.py index 9c83c70c..fbd6de6d 100644 --- a/copyparty/ftpd.py +++ b/copyparty/ftpd.py @@ -113,7 +113,8 @@ class FtpFs(AbstractedFS): def __init__( self, root: str, cmd_channel: Any ) -> None: # pylint: disable=super-init-not-called - self.h = self.cmd_channel = cmd_channel # type: FTPHandler + self.h = cmd_channel # type: FTPHandler + self.cmd_channel = cmd_channel # type: FTPHandler self.hub: "SvcHub" = cmd_channel.hub self.args = cmd_channel.args self.uname = cmd_channel.uname diff --git a/copyparty/th_srv.py b/copyparty/th_srv.py index adb9a0fb..1c40e9ff 100644 --- a/copyparty/th_srv.py +++ b/copyparty/th_srv.py @@ -274,6 +274,10 @@ class ThumbSrv(object): tdir, tfn = os.path.split(tpath) ttpath = os.path.join(tdir, "w", tfn) + try: + bos.unlink(ttpath) + except: + pass for fun in funs: try: @@ -570,11 +574,15 @@ class ThumbSrv(object): want_caf = tpath.endswith(".caf") tmp_opus = tpath if want_caf: - tmp_opus = tpath.rsplit(".", 1)[0] + ".opus" + tmp_opus = tpath + ".opus" + try: + bos.unlink(tmp_opus) + except: + pass caf_src = abspath if src_opus else tmp_opus - if not want_caf or (not src_opus and not bos.path.isfile(tmp_opus)): + if not want_caf or not src_opus: # fmt: off cmd = [ b"ffmpeg", @@ -633,6 +641,12 @@ class ThumbSrv(object): # fmt: on self._run_ff(cmd) + if tmp_opus != tpath: + try: + bos.unlink(tmp_opus) + except: + pass + def poke(self, tdir: str) -> None: if not self.poke_cd.poke(tdir): return diff --git a/copyparty/util.py b/copyparty/util.py index 486e0ad0..94371441 100644 --- a/copyparty/util.py +++ b/copyparty/util.py @@ -613,7 +613,7 @@ class _LUnrecv(object): def recv_ex(self, nbytes: int, raise_on_trunc: bool = True) -> bytes: """read an exact number of bytes""" try: - ret = self.recv(nbytes) + ret = self.recv(nbytes, 1) err = False except: ret = b"" @@ -621,7 +621,7 @@ class _LUnrecv(object): while not err and len(ret) < nbytes: try: - ret += self.recv(nbytes - len(ret)) + ret += self.recv(nbytes - len(ret), 1) except OSError: err = True diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 1914a2f7..f760d668 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -1482,7 +1482,7 @@ var mpl = (function () { ebi('np_title').textContent = np.title || ''; ebi('np_dur').textContent = np['.dur'] || ''; ebi('np_url').textContent = get_vpath() + np.file.split('?')[0]; - ebi('np_img').setAttribute('src', cover); // dont give last.fm the pwd + ebi('np_img').setAttribute('src', cover || ''); // dont give last.fm the pwd navigator.mediaSession.metadata = new MediaMetadata(tags); navigator.mediaSession.setActionHandler('play', mplay); diff --git a/docs/changelog.md b/docs/changelog.md index cc9fdfef..7223ff09 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,3 +1,22 @@ +▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ +# 2023-0424-0609 `v1.6.14` unsettable flags + +## new features +* unset a volflag (override a global option) by negating it (setting volflag `-flagname`) +* new argument `--cert` to specify TLS certificate location + * defaults to `~/.config/copyparty/cert.pem` like before + +## bugfixes +* in zip/tar downloads, always use the parent-folder name as the archive root +* more reliable ftp authentication when providing password as username +* connect-page: fix rclone ftps example + +## other changes +* stop suggesting `--http-only` and `--https-only` for performance since the difference is negligible +* mention how some antivirus (avast, avg, mcafee) thinks that pillow's webp encoder is a virus, affecting `copyparty.exe` + + + ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ # 2023-0420-2141 `v1.6.12` as seen on nixos diff --git a/tests/util.py b/tests/util.py index 5dedb37d..eb05b319 100644 --- a/tests/util.py +++ b/tests/util.py @@ -98,7 +98,7 @@ class Cfg(Namespace): def __init__(self, a=None, v=None, c=None): ka = {} - ex = "daw dav_inf dav_mac dotsrch e2d e2ds e2dsa e2t e2ts e2tsr e2v e2vu e2vp ed emp force_js getmod hardlink ih ihead magic never_symlink nid nih no_acode no_athumb no_dav no_dedup no_del no_dupe no_logues no_mv no_readme no_robots no_sb_md no_sb_lg no_scandir no_thumb no_vthumb no_zip nrand nw rand vc xdev xlink xvol" + ex = "daw dav_inf dav_mac dav_rt dotsrch e2d e2ds e2dsa e2t e2ts e2tsr e2v e2vu e2vp ed emp force_js getmod hardlink ih ihead magic never_symlink nid nih no_acode no_athumb no_dav no_dedup no_del no_dupe no_logues no_mv no_readme no_robots no_sb_md no_sb_lg no_scandir no_thumb no_vthumb no_zip nrand nw rand vc xdev xlink xvol" ka.update(**{k: False for k in ex.split()}) ex = "dotpart no_rescan no_sendfile no_voldump plain_ip"