mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 17:12:13 -06:00
u2c: when deleting from server, heed request size limit
This commit is contained in:
parent
91f010290c
commit
2077dca66f
17
bin/u2c.py
17
bin/u2c.py
|
@ -907,12 +907,23 @@ class Ctl(object):
|
||||||
dp = os.path.join(top, rd)
|
dp = os.path.join(top, rd)
|
||||||
lnodes = set(os.listdir(dp))
|
lnodes = set(os.listdir(dp))
|
||||||
bnames = [x for x in ls if x not in lnodes]
|
bnames = [x for x in ls if x not in lnodes]
|
||||||
if bnames:
|
|
||||||
vpath = self.ar.url.split("://")[-1].split("/", 1)[-1]
|
vpath = self.ar.url.split("://")[-1].split("/", 1)[-1]
|
||||||
names = [x.decode("utf-8", "replace") for x in bnames]
|
names = [x.decode("utf-8", "replace") for x in bnames]
|
||||||
locs = [vpath + srd + "/" + x for x in names]
|
locs = [vpath + srd + "/" + x for x in names]
|
||||||
print("DELETING ~{0}/#{1}".format(srd, len(names)))
|
while locs:
|
||||||
req_ses.post(self.ar.url + "?delete", json=locs)
|
req = locs
|
||||||
|
while req:
|
||||||
|
print("DELETING ~%s/#%s" % (srd, len(req)))
|
||||||
|
r = req_ses.post(self.ar.url + "?delete", json=req)
|
||||||
|
if r.status_code == 413 and "json 2big" in r.text:
|
||||||
|
print(" (delete request too big; slicing...)")
|
||||||
|
req = req[: len(req) // 2]
|
||||||
|
continue
|
||||||
|
elif not r:
|
||||||
|
t = "delete request failed: %r %s"
|
||||||
|
raise Exception(t % (r, r.text))
|
||||||
|
break
|
||||||
|
locs = locs[len(req) :]
|
||||||
|
|
||||||
if isdir:
|
if isdir:
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in a new issue