From daa9dedcaaa78b542d498d8dd96812ce80db0bb5 Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 26 Jul 2021 00:29:28 +0200 Subject: [PATCH] rm works --- copyparty/up2k.py | 10 +++++----- copyparty/web/browser.js | 30 ++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/copyparty/up2k.py b/copyparty/up2k.py index 737c7274..a5cc99e6 100644 --- a/copyparty/up2k.py +++ b/copyparty/up2k.py @@ -1285,7 +1285,9 @@ class Up2k(object): adir, fn = os.path.split(atop) st = bos.lstat(atop) if stat.S_ISLNK(st.st_mode) or stat.S_ISREG(st.st_mode): - g = [[os.path.dirname(vpath), adir, [[fn, 0]], [], []]] + dbv, vrem = self.asrv.vfs.get(vpath, uname, *permsets[0]) + dbv, vrem = dbv.get_dbv(vrem) + g = [[dbv, vrem, os.path.dirname(vpath), adir, [[fn, 0]], [], []]] else: scandir = not self.args.no_scandir g = vn.walk("", rem, [], uname, permsets, True, scandir, True) @@ -1297,9 +1299,7 @@ class Up2k(object): n_files += 1 abspath = os.path.join(atop, fn) vpath = "{}/{}".format(vrem, fn).strip("/") - self.log("rm file {}\n vpath: {}".format(abspath, vpath)) - # dbv, vrem = self.asrv.vfs.get(vpath, uname, *permsets[0]) - # dbv, vrem = dbv.get_dbv(vrem) + self.log("rm {}\n {}".format(vpath, abspath)) _ = dbv.get(vrem, uname, *permsets[0]) with self.mutex: try: @@ -1482,7 +1482,7 @@ class Up2k(object): self._symlink(sabs, dabs) full[vp1] = sabs - dvp = vp2 if vp2 else full.keys()[0] + dvp = vp2 if vp2 else list(sorted(full.keys()))[0] dabs = gabs(dvp) for alink in links.values(): self.log("relinking [{}] to [{}]".format(alink, dabs)) diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 6d5ca600..0e672381 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -1507,7 +1507,7 @@ var fileman = (function () { vps = []; for (var a = 0; a < sel.length; a++) - vps.push(sel.vp); + vps.push(sel[a].vp); if (!sel.length) return alert('select at least 1 item to delete'); @@ -1518,7 +1518,33 @@ var fileman = (function () { if (!confirm('Last chance! Delete?')) return; - toast.show(vps.length + ' deletes left', 2000); + function deleter() { + var xhr = new XMLHttpRequest(), + vp = vps.shift(); + + if (!vp) { + toast.show('delete OK', 2000); + treectl.goto(get_evpath()); + return; + } + toast.show('deleting ' + (vps.length + 1) + ' items

' + vp, 2000); + + xhr.open('GET', vp + '?delete', true); + xhr.onreadystatechange = delete_cb; + xhr.send(); + } + function delete_cb() { + if (this.readyState != XMLHttpRequest.DONE) + return; + + if (this.status !== 200) { + var msg = this.responseText; + toast.show('delete failed:
' + msg, 2000); + return; + } + deleter(); + } + deleter(); }; r.cut = function (e) {