From 79b7d3316adad1c6cb37bb9b7e0393c681309c81 Mon Sep 17 00:00:00 2001 From: ed Date: Sun, 16 Aug 2020 23:04:10 +0000 Subject: [PATCH] v0.5.0 --- bin/README.md | 13 +++++-- bin/copyparty-fuse.py | 82 ++++++++++++++++++++++++---------------- copyparty/__version__.py | 6 +-- copyparty/httpcli.py | 11 ++++++ copyparty/web/md2.js | 5 +++ 5 files changed, 78 insertions(+), 39 deletions(-) diff --git a/bin/README.md b/bin/README.md index 232890d6..ba5cceca 100644 --- a/bin/README.md +++ b/bin/README.md @@ -1,8 +1,15 @@ # copyparty-fuse.py * mount a copyparty server as a local filesystem (read-only) -* **supports Linux** -- expect `117 MiB/s` sequential read over wifi -* **supports Windows!** -- expect `87 MiB/s` sequential read over wifi -* **supports macos** -- expect `17 MiB/s` sequential read over wifi +* **supports Windows!** -- expect `194 MiB/s` sequential read +* **supports Linux** -- expect `117 MiB/s` sequential read +* **supports macos** -- expect `85 MiB/s` sequential read + +filecache is default-on for windows and macos; +* macos readsize is 64kB, so speed ~32 MiB/s without the cache +* windows readsize varies by software; explorer=1M, pv=32k + +note that copyparty should run with `-ed` to enable dotfiles (hidden otherwise) + ## to run this on windows: * install [winfsp](https://github.com/billziss-gh/winfsp/releases/latest) and [python 3](https://www.python.org/downloads/) diff --git a/bin/copyparty-fuse.py b/bin/copyparty-fuse.py index 294396a1..3baccb6d 100755 --- a/bin/copyparty-fuse.py +++ b/bin/copyparty-fuse.py @@ -7,6 +7,21 @@ __copyright__ = 2019 __license__ = "MIT" __url__ = "https://github.com/9001/copyparty/" + +""" +mount a copyparty server (local or remote) as a filesystem + +usage: + python copyparty-fuse.py ./music http://192.168.1.69:3923/ + +dependencies: + python3 -m pip install --user fusepy + + on Linux: sudo apk add fuse + + on Macos: https://osxfuse.github.io/ + + on Windows: https://github.com/billziss-gh/winfsp/releases/latest +""" + + import re import os import sys @@ -15,6 +30,7 @@ import stat import errno import struct import builtins +import platform import threading import traceback import http.client # py2: httplib @@ -22,34 +38,31 @@ import urllib.parse from datetime import datetime from urllib.parse import quote_from_bytes as quote -try: - from fuse import FUSE, FuseOSError, Operations -except: - print( - "\n could not import fuse; these may help:\n python3 -m pip install --user fusepy\n apt install libfuse\n modprobe fuse\n" - ) - raise - - -""" -mount a copyparty server (local or remote) as a filesystem - -usage: - python copyparty-fuse.py ./music http://192.168.1.69:3923/ - -dependencies (linux/macos): - sudo apk add fuse - python3 -m pip install --user fusepy - -dependencies (windows): - https://github.com/billziss-gh/winfsp/releases/latest - python3 -m pip install --user fusepy -""" - DEBUG = False # ctrl-f this to configure logging + WINDOWS = sys.platform == "win32" +MACOS = platform.system() == "Darwin" + + +try: + from fuse import FUSE, FuseOSError, Operations +except: + if WINDOWS: + libfuse = "install https://github.com/billziss-gh/winfsp/releases/latest" + elif MACOS: + libfuse = "install https://osxfuse.github.io/" + else: + libfuse = "apt install libfuse\n modprobe fuse" + + print( + "\n could not import fuse; these may help:" + + "\n python3 -m pip install --user fusepy\n " + + libfuse + + "\n" + ) + raise def print(*args, **kwargs): @@ -791,7 +804,7 @@ def main(): # linux generally does 128k so the cache is a slowdown, # windows likes to use 4k and 64k so cache is required, # value is numChunks (1~3M each) to keep in the cache - nf = 24 if WINDOWS else 0 + nf = 24 if WINDOWS or MACOS else 0 # dircache is always a boost, # only want to disable it for tests etc, @@ -822,14 +835,17 @@ def main(): if WINDOWS: os.system("") - FUSE( - CPPF(remote, dircache, filecache), - local, - foreground=True, - nothreads=True, - allow_other=True, - nonempty=True, - ) + try: + with open("/etc/fuse.conf", "rb") as f: + allow_other = b"\nuser_allow_other" in f.read() + except: + allow_other = WINDOWS or MACOS + + args = {"foreground": True, "nothreads": True, "allow_other": allow_other} + if not MACOS: + args["nonempty"] = True + + FUSE(CPPF(remote, dircache, filecache), local, **args) if __name__ == "__main__": diff --git a/copyparty/__version__.py b/copyparty/__version__.py index 87fec7bb..30062d06 100644 --- a/copyparty/__version__.py +++ b/copyparty/__version__.py @@ -1,8 +1,8 @@ # coding: utf-8 -VERSION = (0, 4, 3) -CODENAME = "NIH" -BUILD_DT = (2020, 5, 17) +VERSION = (0, 5, 0) +CODENAME = "fuse jelly" +BUILD_DT = (2020, 8, 17) S_VERSION = ".".join(map(str, VERSION)) S_BUILD_DT = "{0:04d}-{1:02d}-{2:02d}".format(*BUILD_DT) diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 09d98c1c..2d3c1ad9 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -1062,6 +1062,17 @@ class HttpCli(object): with open(fsenc(fn), "rb") as f: logues[n] = f.read().decode("utf-8") + if False: + # this is a mistake + md = None + for fn in [x[2] for x in files]: + if fn.lower() == "readme.md": + fn = os.path.join(abspath, fn) + with open(fn, "rb") as f: + md = f.read().decode("utf-8") + + break + ts = "" # ts = "?{}".format(time.time()) diff --git a/copyparty/web/md2.js b/copyparty/web/md2.js index fdb2e19e..f4befa98 100644 --- a/copyparty/web/md2.js +++ b/copyparty/web/md2.js @@ -559,6 +559,11 @@ function md_p_jump(down) { save(); return false; } + if (ev.code == "Escape" || kc == 27) { + var d = document.getElementById('helpclose'); + if (d) + d.click(); + } if (document.activeElement == dom_src) { if (ev.code == "Tab" || kc == 9) { md_indent(ev.shiftKey);