mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 01:22:13 -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):
|
if self.vpath.endswith(k):
|
||||||
self.vpath = self.vpath[: -len(k)]
|
self.vpath = self.vpath[: -len(k)]
|
||||||
|
|
||||||
sub = None
|
|
||||||
name = undot(body["name"])
|
name = undot(body["name"])
|
||||||
if "/" in name:
|
if "/" in name:
|
||||||
sub, name = name.rsplit("/", 1)
|
raise Pebkac(400, "your client is old; press CTRL-SHIFT-R and try again")
|
||||||
self.vpath = "/".join([self.vpath, sub]).strip("/")
|
|
||||||
body["name"] = name
|
|
||||||
|
|
||||||
vfs, rem = self.asrv.vfs.get(self.vpath, self.uname, False, True)
|
vfs, rem = self.asrv.vfs.get(self.vpath, self.uname, False, True)
|
||||||
dbv, vrem = vfs.get_dbv(rem)
|
dbv, vrem = vfs.get_dbv(rem)
|
||||||
|
@ -643,7 +640,7 @@ class HttpCli(object):
|
||||||
body["addr"] = self.ip
|
body["addr"] = self.ip
|
||||||
body["vcfg"] = dbv.flags
|
body["vcfg"] = dbv.flags
|
||||||
|
|
||||||
if sub:
|
if rem:
|
||||||
try:
|
try:
|
||||||
dst = os.path.join(vfs.realpath, rem)
|
dst = os.path.join(vfs.realpath, rem)
|
||||||
if not bos.path.isdir(dst):
|
if not bos.path.isdir(dst):
|
||||||
|
@ -663,9 +660,6 @@ class HttpCli(object):
|
||||||
|
|
||||||
x = self.conn.hsrv.broker.put(True, "up2k.handle_json", body)
|
x = self.conn.hsrv.broker.put(True, "up2k.handle_json", body)
|
||||||
ret = x.get()
|
ret = x.get()
|
||||||
if sub:
|
|
||||||
ret["name"] = "/".join([sub, ret["name"]])
|
|
||||||
|
|
||||||
ret = json.dumps(ret)
|
ret = json.dumps(ret)
|
||||||
self.log(ret)
|
self.log(ret)
|
||||||
self.reply(ret.encode("utf-8"), mime="application/json")
|
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++) {
|
for (var a = 0; a < good_files.length; a++) {
|
||||||
var fobj = good_files[a][0],
|
var fobj = good_files[a][0],
|
||||||
|
name = good_files[a][1],
|
||||||
|
fdir = '',
|
||||||
now = Date.now(),
|
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 = {
|
var entry = {
|
||||||
"n": st.files.length,
|
"n": st.files.length,
|
||||||
"t0": now,
|
"t0": now,
|
||||||
"fobj": fobj,
|
"fobj": fobj,
|
||||||
"name": good_files[a][1],
|
"name": name,
|
||||||
"size": fobj.size,
|
"size": fobj.size,
|
||||||
"lmod": lmod / 1000,
|
"lmod": lmod / 1000,
|
||||||
"purl": evpath,
|
"purl": fdir,
|
||||||
"done": false,
|
"done": false,
|
||||||
"hash": []
|
"hash": []
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue