Skip to content

Commit

Permalink
v0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
9001 committed Aug 16, 2020
1 parent fa77685 commit 79b7d33
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 37 deletions.
13 changes: 10 additions & 3 deletions bin/README.md
Original file line number Diff line number Diff line change
@@ -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/)
Expand Down
78 changes: 47 additions & 31 deletions bin/copyparty-fuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@
__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
Expand All @@ -15,41 +30,39 @@
import errno
import struct
import builtins
import platform
import threading
import traceback
import http.client # py2: httplib
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/
DEBUG = False # ctrl-f this to configure logging

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
"""
WINDOWS = sys.platform == "win32"
MACOS = platform.system() == "Darwin"


DEBUG = False # ctrl-f this to configure logging
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"

WINDOWS = sys.platform == "win32"
print(
"\n could not import fuse; these may help:"
+ "\n python3 -m pip install --user fusepy\n "
+ libfuse
+ "\n"
)
raise


def print(*args, **kwargs):
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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__":
Expand Down
6 changes: 3 additions & 3 deletions copyparty/__version__.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
11 changes: 11 additions & 0 deletions copyparty/httpcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,17 @@ def tx_browser(self):
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())

Expand Down
5 changes: 5 additions & 0 deletions copyparty/web/md2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 79b7d33

Please sign in to comment.