cleanup + readme

This commit is contained in:
ed 2020-08-04 23:46:57 +00:00
parent b2b083fd0a
commit e0e6291bdb
3 changed files with 57 additions and 14 deletions

16
bin/README.md Normal file
View file

@ -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

33
bin/copyparty-fuse.py Normal file → Executable file
View file

@ -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():

22
bin/copyparty-fuseb.py Normal file → Executable file
View file

@ -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__":