fuse: windows howto

This commit is contained in:
ed 2020-08-06 18:22:25 +00:00
parent e0e6291bdb
commit 82441978c6
3 changed files with 39 additions and 24 deletions

View file

@ -4,10 +4,21 @@
* **supports Windows!** -- expect `87 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 macos** -- expect `17 MiB/s` sequential read over wifi
to run this on windows you ## to run this on windows:
* definitely need `msys2` * install [winfsp](https://github.com/billziss-gh/winfsp/releases/latest) and [python 3](https://www.python.org/downloads/)
* probably need `dokany` or `winfsp`, not sure which #todo * [x] add python 3.x to PATH (it asks during install)
* should do this `/mingw64/bin/python3 ./copyparty-fuse.py n: http://192.168.1.69:3923/` * `python -m pip install --user fusepy`
* `python ./copyparty-fuse.py n: http://192.168.1.69:3923/`
10% faster in [msys2](https://www.msys2.org/), 700% faster if debug prints are enabled:
* `pacman -S mingw64/mingw-w64-x86_64-python{,-pip}`
* `/mingw64/bin/python3 -m pip install --user fusepy`
* `/mingw64/bin/python3 ./copyparty-fuse.py [...]`
you could replace winfsp with [dokan](https://github.com/dokan-dev/dokany/releases/latest), let me know if you [figure out how](https://github.com/dokan-dev/dokany/wiki/FUSE)
(winfsp's sshfs leaks, doesn't look like winfsp itself does, should be fine)
# 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)

View file

@ -8,6 +8,7 @@ __license__ = "MIT"
__url__ = "https://github.com/9001/copyparty/" __url__ = "https://github.com/9001/copyparty/"
import re import re
import os
import sys import sys
import time import time
import stat import stat
@ -24,7 +25,7 @@ try:
from fuse import FUSE, FuseOSError, Operations from fuse import FUSE, FuseOSError, Operations
except: except:
print( print(
"\n could not import fuse; these may help:\n python3 -m pip install --user fusepy\n apt install libfuse\n modprobe fuse" "\n could not import fuse; these may help:\n python3 -m pip install --user fusepy\n apt install libfuse\n modprobe fuse\n"
) )
raise raise
@ -38,17 +39,12 @@ usage:
dependencies: dependencies:
sudo apk add fuse sudo apk add fuse
python3 -m pip install --user fusepy python3 -m pip install --user fusepy
MB/s
28 cache NOthread
24 cache thread
29 cache NOthread NOmutex
67 NOcache NOthread NOmutex ( ´ω) nyoro~n
10 NOcache thread NOmutex
""" """
WINDOWS = sys.platform == 'win32'
def print(*args, **kwargs): def print(*args, **kwargs):
try: try:
builtins.print(*list(args), **kwargs) builtins.print(*list(args), **kwargs)
@ -283,8 +279,7 @@ class CPPF(Operations):
self.dircache = self.dircache[cutoff:] self.dircache = self.dircache[cutoff:]
def get_cached_dir(self, dirpath): def get_cached_dir(self, dirpath):
# with self.dircache_mtx: with self.dircache_mtx:
if True:
self.clean_dircache() self.clean_dircache()
for cn in self.dircache: for cn in self.dircache:
if cn.tag == dirpath: if cn.tag == dirpath:
@ -321,8 +316,7 @@ class CPPF(Operations):
car = None car = None
cdr = None cdr = None
ncn = -1 ncn = -1
# with self.filecache_mtx: with self.filecache_mtx:
if True:
dbg("cache request from {} to {}, size {}".format(get1, get2, file_sz)) dbg("cache request from {} to {}, size {}".format(get1, get2, file_sz))
for cn in self.filecache: for cn in self.filecache:
ncn += 1 ncn += 1
@ -463,8 +457,7 @@ class CPPF(Operations):
ret = buf[buf_ofs:buf_end] ret = buf[buf_ofs:buf_end]
cn = CacheNode([path, h_ofs], buf) cn = CacheNode([path, h_ofs], buf)
# with self.filecache_mtx: with self.filecache_mtx:
if True:
if len(self.filecache) > 6: if len(self.filecache) > 6:
self.filecache = self.filecache[1:] + [cn] self.filecache = self.filecache[1:] + [cn]
else: else:
@ -478,8 +471,7 @@ class CPPF(Operations):
ret = self.gw.listdir(path) ret = self.gw.listdir(path)
# with self.dircache_mtx: with self.dircache_mtx:
if True:
cn = CacheNode(path, ret) cn = CacheNode(path, ret)
self.dircache.append(cn) self.dircache.append(cn)
self.clean_dircache() self.clean_dircache()
@ -632,12 +624,24 @@ def main():
try: try:
local, remote = sys.argv[1:] local, remote = sys.argv[1:]
except: except:
print("need arg 1: local directory") where = "local directory"
if WINDOWS:
where += " or DRIVE:"
print("need arg 1: " + where)
print("need arg 2: root url") print("need arg 2: root url")
print()
print("example:")
print(" copyparty-fuse.py ./music http://192.168.1.69:3923/music/")
if WINDOWS:
print(" copyparty-fuse.py M: http://192.168.1.69:3923/music/")
return return
if WINDOWS:
os.system("")
FUSE(CPPF(remote), local, foreground=True, nothreads=True, allow_other=True, nonempty=True) FUSE(CPPF(remote), local, foreground=True, nothreads=True, allow_other=True, nonempty=True)
# if nothreads=False also uncomment the `with *_mtx` things
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -28,7 +28,7 @@ try:
raise Exception('your fuse-python is way old') raise Exception('your fuse-python is way old')
except: except:
print( print(
"\n could not import fuse; these may help:\n python3 -m pip install --user fuse-python\n apt install libfuse\n modprobe fuse" "\n could not import fuse; these may help:\n python3 -m pip install --user fuse-python\n apt install libfuse\n modprobe fuse\n"
) )
raise raise