From e0e6291bdbf6b26da742bed8c8ed9c13ffc8ce71 Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 4 Aug 2020 23:46:57 +0000 Subject: [PATCH] cleanup + readme --- bin/README.md | 16 ++++++++++++++++ bin/copyparty-fuse.py | 33 +++++++++++++++++++++++++-------- bin/copyparty-fuseb.py | 22 ++++++++++++++++------ 3 files changed, 57 insertions(+), 14 deletions(-) create mode 100644 bin/README.md mode change 100644 => 100755 bin/copyparty-fuse.py mode change 100644 => 100755 bin/copyparty-fuseb.py diff --git a/bin/README.md b/bin/README.md new file mode 100644 index 00000000..005f3281 --- /dev/null +++ b/bin/README.md @@ -0,0 +1,16 @@ +# 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 + +to run this on windows you +* definitely need `msys2` +* probably need `dokany` or `winfsp`, not sure which #todo +* should do this `/mingw64/bin/python3 ./copyparty-fuse.py n: http://192.168.1.69:3923/` + +# copyparty-fuse🅱️.py +* mount a copyparty server as a local filesystem (read-only) +* does the same thing except more correct, `samba` approves +* **supports Linux** -- expect `18 MiB/s` (wait what) +* **supports Macos** -- probably diff --git a/bin/copyparty-fuse.py b/bin/copyparty-fuse.py old mode 100644 new mode 100755 index e8121776..8c0ab041 --- a/bin/copyparty-fuse.py +++ b/bin/copyparty-fuse.py @@ -36,7 +36,7 @@ usage: python copyparty-fuse.py ./music http://192.168.1.69:3923/ dependencies: - sudo apk add fuse-dev + sudo apk add fuse python3 -m pip install --user fusepy @@ -474,7 +474,7 @@ class CPPF(Operations): def readdir(self, path, fh=None): path = path.strip("/") - log("readdir {}".format(path)) + log("readdir [{}] [{}]".format(path, fh)) ret = self.gw.listdir(path) @@ -532,7 +532,7 @@ class CPPF(Operations): dbg("=" + repr(cache_stat)) return cache_stat - log("=404") + log("=404 ({})".format(path)) raise FuseOSError(errno.ENOENT) access = None @@ -585,8 +585,7 @@ class CPPF(Operations): if sys.platform == 'win32': # quick compat for /mingw64/bin/python3 (msys2) - def open(self, path, flags): - log("open [{}] [{}]".format(path, flags)) + def _open(self, path): try: x = self.getattr(path) if x["st_mode"] <= 0: @@ -594,7 +593,7 @@ class CPPF(Operations): self.junk_fh_ctr += 1 if self.junk_fh_ctr > 32000: # TODO untested - self.junk_fh_ctr = 4 + self.junk_fh_ctr = 4 return self.junk_fh_ctr @@ -602,13 +601,31 @@ class CPPF(Operations): log("open ERR {}".format(repr(ex))) raise FuseOSError(errno.ENOENT) + def open(self, path, flags): + log("open [{}] [{}]".format(path, flags)) + return self._open(path) + + def opendir(self, path): + log("opendir [{}]".format(path)) + return self._open(path) + def flush(self, path, fh): log("flush [{}] [{}]".format(path, fh)) - return True def release(self, ino, fi): log("release [{}] [{}]".format(ino, fi)) - return True + + def releasedir(self, ino, fi): + log("releasedir [{}] [{}]".format(ino, fi)) + + def access(self, path, mode): + log("access [{}] [{}]".format(path, mode)) + try: + x = self.getattr(path) + if x["st_mode"] <= 0: + raise Exception() + except: + raise FuseOSError(errno.ENOENT) def main(): diff --git a/bin/copyparty-fuseb.py b/bin/copyparty-fuseb.py old mode 100644 new mode 100755 index 693f6e97..6f0adcbd --- a/bin/copyparty-fuseb.py +++ b/bin/copyparty-fuseb.py @@ -37,10 +37,10 @@ except: mount a copyparty server (local or remote) as a filesystem usage: - python ./copyparty-fuseb.py -f -o allow_other,auto_unmount,nonempty,url=http://192.168.1.69:3923 /export/ro + python ./copyparty-fuseb.py -f -o allow_other,auto_unmount,nonempty,url=http://192.168.1.69:3923 /mnt/nas dependencies: - sudo apk add fuse-dev + sudo apk add fuse-dev python3-dev python3 -m pip install --user fuse-python fork of copyparty-fuse.py based on fuse-python which @@ -540,7 +540,7 @@ class CPPF(Fuse): if not path: ret = self.gw.stat_dir(time.time()) - log("=root") + dbg("=root") return ret cn = self.get_cached_dir(dirpath) @@ -553,7 +553,7 @@ class CPPF(Fuse): for cache_name, cache_stat, _ in dents: if cache_name == fname: - log("=file") + dbg("=file") return cache_stat log("=404") @@ -562,10 +562,20 @@ class CPPF(Fuse): def main(): server = CPPF() - server.parser.add_option(mountopt="url", metavar="BASE_URL", default='http://127.0.0.1:3923/') + server.parser.add_option(mountopt="url", metavar="BASE_URL", default=None) server.parse(values=server, errex=1) + if not server.url or not str(server.url).startswith('http'): + print('\nerror:') + print(' need argument: -o url=<...>') + print(' need argument: mount-path') + print('example:') + print(' ./copyparty-fuseb.py -f -o allow_other,auto_unmount,nonempty,url=http://192.168.1.69:3923 /mnt/nas') + sys.exit(1) + server.init2() - server.main() + threading.Thread(target=server.main, daemon=True).start() + while True: + time.sleep(9001) if __name__ == "__main__":