mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
partyfuse: misc correctness;
* support more unix envs with granular fuse config * generated URLs were OK but technically incorrect
This commit is contained in:
parent
fcdc1728eb
commit
73d05095b5
|
@ -258,6 +258,7 @@ class Gateway(object):
|
||||||
|
|
||||||
ui = urllib.parse.urlparse(self.base_url)
|
ui = urllib.parse.urlparse(self.base_url)
|
||||||
self.web_root = ui.path.strip("/")
|
self.web_root = ui.path.strip("/")
|
||||||
|
self.SRS = "/%s/" % (self.web_root,) if self.web_root else "/"
|
||||||
try:
|
try:
|
||||||
self.web_host, self.web_port = ui.netloc.split(":")
|
self.web_host, self.web_port = ui.netloc.split(":")
|
||||||
self.web_port = int(self.web_port)
|
self.web_port = int(self.web_port)
|
||||||
|
@ -346,7 +347,8 @@ class Gateway(object):
|
||||||
if bad_good:
|
if bad_good:
|
||||||
path = dewin(path)
|
path = dewin(path)
|
||||||
|
|
||||||
web_path = self.quotep("/" + "/".join([self.web_root, path])) + "?dots&ls"
|
zs = "%s%s/" if path else "%s%s"
|
||||||
|
web_path = self.quotep(zs % (self.SRS, path)) + "?ls<&dots"
|
||||||
r = self.sendreq("GET", web_path, {})
|
r = self.sendreq("GET", web_path, {})
|
||||||
if r.status != 200:
|
if r.status != 200:
|
||||||
self.closeconn()
|
self.closeconn()
|
||||||
|
@ -372,8 +374,10 @@ class Gateway(object):
|
||||||
if bad_good:
|
if bad_good:
|
||||||
path = dewin(path)
|
path = dewin(path)
|
||||||
|
|
||||||
web_path = self.quotep("/" + "/".join([self.web_root, path])) + "?raw"
|
zs = "%s%s/" if path else "%s%s"
|
||||||
hdr_range = "bytes={}-{}".format(ofs1, ofs2 - 1)
|
web_path = self.quotep(zs % (self.SRS, path)) + "?raw"
|
||||||
|
hdr_range = "bytes=%d-%d" % (ofs1, ofs2 - 1)
|
||||||
|
|
||||||
t = "DL %4.0fK\033[36m%9d-%-9d\033[0m%r"
|
t = "DL %4.0fK\033[36m%9d-%-9d\033[0m%r"
|
||||||
info(t, (ofs2 - ofs1) / 1024.0, ofs1, ofs2 - 1, path)
|
info(t, (ofs2 - ofs1) / 1024.0, ofs1, ofs2 - 1, path)
|
||||||
|
|
||||||
|
@ -485,6 +489,8 @@ class Gateway(object):
|
||||||
|
|
||||||
class CPPF(Operations):
|
class CPPF(Operations):
|
||||||
def __init__(self, ar):
|
def __init__(self, ar):
|
||||||
|
self.use_ns = True
|
||||||
|
|
||||||
self.gw = Gateway(ar)
|
self.gw = Gateway(ar)
|
||||||
self.junk_fh_ctr = 3
|
self.junk_fh_ctr = 3
|
||||||
self.n_dircache = ar.cd
|
self.n_dircache = ar.cd
|
||||||
|
@ -997,6 +1003,10 @@ def main():
|
||||||
ap2.add_argument("--slowterm", action="store_true", help="only most recent msgs; good for windows")
|
ap2.add_argument("--slowterm", action="store_true", help="only most recent msgs; good for windows")
|
||||||
ap2.add_argument("--logf", metavar="FILE", type=str, default="", help="log to FILE; enables --slowterm")
|
ap2.add_argument("--logf", metavar="FILE", type=str, default="", help="log to FILE; enables --slowterm")
|
||||||
|
|
||||||
|
ap2 = ap.add_argument_group("fuse")
|
||||||
|
ap2.add_argument("--oth", action="store_true", help="tell FUSE to '-o allow_other'")
|
||||||
|
ap2.add_argument("--nonempty", action="store_true", help="tell FUSE to '-o nonempty'")
|
||||||
|
|
||||||
ar = ap.parse_args()
|
ar = ap.parse_args()
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
|
@ -1036,14 +1046,10 @@ def main():
|
||||||
|
|
||||||
register_wtf8()
|
register_wtf8()
|
||||||
|
|
||||||
try:
|
args = {"foreground": True, "nothreads": True}
|
||||||
with open("/etc/fuse.conf", "rb") as f:
|
if ar.oth:
|
||||||
allow_other = b"\nuser_allow_other" in f.read()
|
args["allow_other"] = True
|
||||||
except:
|
if ar.nonempty:
|
||||||
allow_other = WINDOWS or MACOS
|
|
||||||
|
|
||||||
args = {"foreground": True, "nothreads": True, "allow_other": allow_other}
|
|
||||||
if not MACOS:
|
|
||||||
args["nonempty"] = True
|
args["nonempty"] = True
|
||||||
|
|
||||||
FUSE(CPPF(ar), ar.local_path, encoding="wtf-8", **args)
|
FUSE(CPPF(ar), ar.local_path, encoding="wtf-8", **args)
|
||||||
|
|
Loading…
Reference in a new issue