This commit is contained in:
ed 2020-08-16 23:04:10 +00:00
parent fa7768583a
commit 79b7d3316a
5 changed files with 78 additions and 39 deletions

View file

@ -1,8 +1,15 @@
# copyparty-fuse.py # copyparty-fuse.py
* mount a copyparty server as a local filesystem (read-only) * mount a copyparty server as a local filesystem (read-only)
* **supports Linux** -- expect `117 MiB/s` sequential read over wifi * **supports Windows!** -- expect `194 MiB/s` sequential read
* **supports Windows!** -- expect `87 MiB/s` sequential read over wifi * **supports Linux** -- expect `117 MiB/s` sequential read
* **supports macos** -- expect `17 MiB/s` sequential read over wifi * **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: ## to run this on windows:
* install [winfsp](https://github.com/billziss-gh/winfsp/releases/latest) and [python 3](https://www.python.org/downloads/) * install [winfsp](https://github.com/billziss-gh/winfsp/releases/latest) and [python 3](https://www.python.org/downloads/)

View file

@ -7,6 +7,21 @@ __copyright__ = 2019
__license__ = "MIT" __license__ = "MIT"
__url__ = "https://github.com/9001/copyparty/" __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 re
import os import os
import sys import sys
@ -15,6 +30,7 @@ import stat
import errno import errno
import struct import struct
import builtins import builtins
import platform
import threading import threading
import traceback import traceback
import http.client # py2: httplib import http.client # py2: httplib
@ -22,34 +38,31 @@ import urllib.parse
from datetime import datetime from datetime import datetime
from urllib.parse import quote_from_bytes as quote 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 DEBUG = False # ctrl-f this to configure logging
WINDOWS = sys.platform == "win32" 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): def print(*args, **kwargs):
@ -791,7 +804,7 @@ def main():
# linux generally does 128k so the cache is a slowdown, # linux generally does 128k so the cache is a slowdown,
# windows likes to use 4k and 64k so cache is required, # windows likes to use 4k and 64k so cache is required,
# value is numChunks (1~3M each) to keep in the cache # 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, # dircache is always a boost,
# only want to disable it for tests etc, # only want to disable it for tests etc,
@ -822,14 +835,17 @@ def main():
if WINDOWS: if WINDOWS:
os.system("") os.system("")
FUSE( try:
CPPF(remote, dircache, filecache), with open("/etc/fuse.conf", "rb") as f:
local, allow_other = b"\nuser_allow_other" in f.read()
foreground=True, except:
nothreads=True, allow_other = WINDOWS or MACOS
allow_other=True,
nonempty=True, 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__": if __name__ == "__main__":

View file

@ -1,8 +1,8 @@
# coding: utf-8 # coding: utf-8
VERSION = (0, 4, 3) VERSION = (0, 5, 0)
CODENAME = "NIH" CODENAME = "fuse jelly"
BUILD_DT = (2020, 5, 17) BUILD_DT = (2020, 8, 17)
S_VERSION = ".".join(map(str, VERSION)) S_VERSION = ".".join(map(str, VERSION))
S_BUILD_DT = "{0:04d}-{1:02d}-{2:02d}".format(*BUILD_DT) S_BUILD_DT = "{0:04d}-{1:02d}-{2:02d}".format(*BUILD_DT)

View file

@ -1062,6 +1062,17 @@ class HttpCli(object):
with open(fsenc(fn), "rb") as f: with open(fsenc(fn), "rb") as f:
logues[n] = f.read().decode("utf-8") 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 = ""
# ts = "?{}".format(time.time()) # ts = "?{}".format(time.time())

View file

@ -559,6 +559,11 @@ function md_p_jump(down) {
save(); save();
return false; return false;
} }
if (ev.code == "Escape" || kc == 27) {
var d = document.getElementById('helpclose');
if (d)
d.click();
}
if (document.activeElement == dom_src) { if (document.activeElement == dom_src) {
if (ev.code == "Tab" || kc == 9) { if (ev.code == "Tab" || kc == 9) {
md_indent(ev.shiftKey); md_indent(ev.shiftKey);