mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 01:22:13 -06:00
rclone faster + query params correctness
This commit is contained in:
parent
e62bb807a5
commit
9bb1323e44
|
@ -120,29 +120,31 @@ class HttpCli(object):
|
||||||
else:
|
else:
|
||||||
uparam[k.lower()] = False
|
uparam[k.lower()] = False
|
||||||
|
|
||||||
|
cookies = self.headers.get("cookie") or {}
|
||||||
|
if cookies:
|
||||||
|
cookies = [x.split("=", 1) for x in cookies.split(";") if "=" in x]
|
||||||
|
cookies = {k.strip(): unescape_cookie(v) for k, v in cookies}
|
||||||
|
for kc, ku in [["cppwd", "pw"], ["b", "b"]]:
|
||||||
|
if kc in cookies and ku not in uparam:
|
||||||
|
uparam[ku] = cookies[kc]
|
||||||
|
|
||||||
self.uparam = uparam
|
self.uparam = uparam
|
||||||
|
self.cookies = cookies
|
||||||
self.vpath = unquotep(vpath)
|
self.vpath = unquotep(vpath)
|
||||||
|
|
||||||
pwd = None
|
pwd = uparam.get("pw")
|
||||||
if "cookie" in self.headers:
|
|
||||||
cookies = self.headers["cookie"].split(";")
|
|
||||||
for k, v in [x.split("=", 1) for x in cookies]:
|
|
||||||
if k.strip() != "cppwd":
|
|
||||||
continue
|
|
||||||
|
|
||||||
pwd = unescape_cookie(v)
|
|
||||||
break
|
|
||||||
|
|
||||||
pwd = uparam.get("pw", pwd)
|
|
||||||
self.uname = self.auth.iuser.get(pwd, "*")
|
self.uname = self.auth.iuser.get(pwd, "*")
|
||||||
if self.uname:
|
if self.uname:
|
||||||
self.rvol = self.auth.vfs.user_tree(self.uname, readable=True)
|
self.rvol = self.auth.vfs.user_tree(self.uname, readable=True)
|
||||||
self.wvol = self.auth.vfs.user_tree(self.uname, writable=True)
|
self.wvol = self.auth.vfs.user_tree(self.uname, writable=True)
|
||||||
|
|
||||||
ua = self.headers.get("user-agent", "")
|
ua = self.headers.get("user-agent", "")
|
||||||
if ua.startswith("rclone/"):
|
self.is_rclone = ua.startswith("rclone/")
|
||||||
|
if self.is_rclone:
|
||||||
uparam["raw"] = False
|
uparam["raw"] = False
|
||||||
uparam["dots"] = False
|
uparam["dots"] = False
|
||||||
|
uparam["b"] = False
|
||||||
|
cookies["b"] = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if self.mode in ["GET", "HEAD"]:
|
if self.mode in ["GET", "HEAD"]:
|
||||||
|
@ -218,7 +220,14 @@ class HttpCli(object):
|
||||||
removing anything in rm, adding pairs in add
|
removing anything in rm, adding pairs in add
|
||||||
"""
|
"""
|
||||||
|
|
||||||
kv = {k: v for k, v in self.uparam.items() if k not in rm}
|
if self.is_rclone:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
kv = {
|
||||||
|
k: v
|
||||||
|
for k, v in self.uparam.items()
|
||||||
|
if k not in rm and self.cookies.get(k) != v
|
||||||
|
}
|
||||||
kv.update(add)
|
kv.update(add)
|
||||||
if not kv:
|
if not kv:
|
||||||
return ""
|
return ""
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
<div>{{ logues[1] }}</div><br />
|
<div>{{ logues[1] }}</div><br />
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
<h2><a href="{{ url_suf }}&h">control-panel</a></h2>
|
<h2><a href="{{ url_suf }}{{ url_suf and '&' or '?' }}h">control-panel</a></h2>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue