mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
up2k-cli: handle subfolders better
This commit is contained in:
parent
66e21bd499
commit
46e7fa31fe
|
@ -627,12 +627,9 @@ class HttpCli(object):
|
|||
if self.vpath.endswith(k):
|
||||
self.vpath = self.vpath[: -len(k)]
|
||||
|
||||
sub = None
|
||||
name = undot(body["name"])
|
||||
if "/" in name:
|
||||
sub, name = name.rsplit("/", 1)
|
||||
self.vpath = "/".join([self.vpath, sub]).strip("/")
|
||||
body["name"] = name
|
||||
raise Pebkac(400, "your client is old; press CTRL-SHIFT-R and try again")
|
||||
|
||||
vfs, rem = self.asrv.vfs.get(self.vpath, self.uname, False, True)
|
||||
dbv, vrem = vfs.get_dbv(rem)
|
||||
|
@ -643,7 +640,7 @@ class HttpCli(object):
|
|||
body["addr"] = self.ip
|
||||
body["vcfg"] = dbv.flags
|
||||
|
||||
if sub:
|
||||
if rem:
|
||||
try:
|
||||
dst = os.path.join(vfs.realpath, rem)
|
||||
if not bos.path.isdir(dst):
|
||||
|
@ -663,9 +660,6 @@ class HttpCli(object):
|
|||
|
||||
x = self.conn.hsrv.broker.put(True, "up2k.handle_json", body)
|
||||
ret = x.get()
|
||||
if sub:
|
||||
ret["name"] = "/".join([sub, ret["name"]])
|
||||
|
||||
ret = json.dumps(ret)
|
||||
self.log(ret)
|
||||
self.reply(ret.encode("utf-8"), mime="application/json")
|
||||
|
|
|
@ -814,17 +814,25 @@ function up2k_init(subtle) {
|
|||
|
||||
for (var a = 0; a < good_files.length; a++) {
|
||||
var fobj = good_files[a][0],
|
||||
name = good_files[a][1],
|
||||
fdir = '',
|
||||
now = Date.now(),
|
||||
lmod = fobj.lastModified || now;
|
||||
lmod = fobj.lastModified || now,
|
||||
ofs = name.lastIndexOf('/') + 1;
|
||||
|
||||
if (ofs) {
|
||||
fdir = name.slice(0, ofs);
|
||||
name = name.slice(ofs);
|
||||
}
|
||||
|
||||
var entry = {
|
||||
"n": st.files.length,
|
||||
"t0": now,
|
||||
"fobj": fobj,
|
||||
"name": good_files[a][1],
|
||||
"name": name,
|
||||
"size": fobj.size,
|
||||
"lmod": lmod / 1000,
|
||||
"purl": evpath,
|
||||
"purl": fdir,
|
||||
"done": false,
|
||||
"hash": []
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue