performance / cosmetic:

* js: use .call instead of .bind when possible
* when running without e2d, the message on startup regarding
  unfinished uploads didn't show the correct filesystem path
This commit is contained in:
ed 2023-08-16 19:32:43 +00:00
parent 0a48acf6be
commit 015b87ee99
5 changed files with 17 additions and 17 deletions

View file

@ -791,9 +791,9 @@ class Up2k(object):
reg = {} reg = {}
drp = None drp = None
path = os.path.join(histpath, "up2k.snap") snap = os.path.join(histpath, "up2k.snap")
if bos.path.exists(path): if bos.path.exists(snap):
with gzip.GzipFile(path, "rb") as f: with gzip.GzipFile(snap, "rb") as f:
j = f.read().decode("utf-8") j = f.read().decode("utf-8")
reg2 = json.loads(j) reg2 = json.loads(j)
@ -804,20 +804,20 @@ class Up2k(object):
pass pass
for k, job in reg2.items(): for k, job in reg2.items():
path = djoin(job["ptop"], job["prel"], job["name"]) fp = djoin(job["ptop"], job["prel"], job["name"])
if bos.path.exists(path): if bos.path.exists(fp):
reg[k] = job reg[k] = job
job["poke"] = time.time() job["poke"] = time.time()
job["busy"] = {} job["busy"] = {}
else: else:
self.log("ign deleted file in snap: [{}]".format(path)) self.log("ign deleted file in snap: [{}]".format(fp))
if drp is None: if drp is None:
drp = [k for k, v in reg.items() if not v.get("need", [])] drp = [k for k, v in reg.items() if not v.get("need", [])]
else: else:
drp = [x for x in drp if x in reg] drp = [x for x in drp if x in reg]
t = "loaded snap {} |{}| ({})".format(path, len(reg.keys()), len(drp or [])) t = "loaded snap {} |{}| ({})".format(snap, len(reg.keys()), len(drp or []))
ta = [t] + self._vis_reg_progress(reg) ta = [t] + self._vis_reg_progress(reg)
self.log("\n".join(ta)) self.log("\n".join(ta))

View file

@ -310,7 +310,7 @@ window.baguetteBox = (function () {
options = {}; options = {};
setOptions(o); setOptions(o);
if (tt.en) if (tt.en)
tt.show.bind(this)(); tt.show.call(this);
} }
function setVmode() { function setVmode() {
@ -356,7 +356,7 @@ window.baguetteBox = (function () {
setVmode(); setVmode();
if (tt.en) if (tt.en)
tt.show.bind(this)(); tt.show.call(this);
} }
function findfile() { function findfile() {

View file

@ -4310,14 +4310,14 @@ var thegrid = (function () {
if (ctrl(e) && !treectl.csel && !r.sel) if (ctrl(e) && !treectl.csel && !r.sel)
return true; return true;
return gclick.bind(this)(e, false); return gclick.call(this, e, false);
} }
function gclick2(e) { function gclick2(e) {
if (ctrl(e) || !r.sel) if (ctrl(e) || !r.sel)
return true; return true;
return gclick.bind(this)(e, true); return gclick.call(this, e, true);
} }
function gclick(e, dbl) { function gclick(e, dbl) {
@ -4332,7 +4332,7 @@ var thegrid = (function () {
tr = td.parentNode; tr = td.parentNode;
if ((r.sel && !dbl && !ctrl(e)) || (treectl.csel && (e.shiftKey || ctrl(e)))) { if ((r.sel && !dbl && !ctrl(e)) || (treectl.csel && (e.shiftKey || ctrl(e)))) {
td.onclick.bind(td)(e); td.onclick.call(td, e);
if (e.shiftKey) if (e.shiftKey)
return r.loadsel(); return r.loadsel();
clmod(this, 'sel', clgot(tr, 'sel')); clmod(this, 'sel', clgot(tr, 'sel'));

View file

@ -971,7 +971,7 @@ function up2k_init(subtle) {
if (++nenters <= 0) if (++nenters <= 0)
nenters = 1; nenters = 1;
if (onover.bind(this)(e)) if (onover.call(this, e))
return true; return true;
var mup, up = QS('#up_zd'); var mup, up = QS('#up_zd');
@ -995,7 +995,7 @@ function up2k_init(subtle) {
function onoverb(e) { function onoverb(e) {
// zones are alive; disable cuo2duo branch // zones are alive; disable cuo2duo branch
document.body.ondragover = document.body.ondrop = null; document.body.ondragover = document.body.ondrop = null;
return onover.bind(this)(e); return onover.call(this, e);
} }
function onover(e) { function onover(e) {
return onovercmn(this, e, false); return onovercmn(this, e, false);
@ -1106,7 +1106,7 @@ function up2k_init(subtle) {
function gotfile(e) { function gotfile(e) {
ev(e); ev(e);
nenters = 0; nenters = 0;
offdrag.bind(this)(); offdrag.call(this);
var dz = this && this.getAttribute('id'); var dz = this && this.getAttribute('id');
if (!dz && e && e.clientY) if (!dz && e && e.clientY)
// cuo2duo fallback // cuo2duo fallback

View file

@ -1165,7 +1165,7 @@ var tt = (function () {
var prev = null; var prev = null;
r.cshow = function () { r.cshow = function () {
if (this !== prev) if (this !== prev)
r.show.bind(this)(); r.show.call(this);
prev = this; prev = this;
}; };
@ -1177,7 +1177,7 @@ var tt = (function () {
return; return;
if (Date.now() - r.lvis < 400) if (Date.now() - r.lvis < 400)
return r.show.bind(this)(); return r.show.call(this);
tev = setTimeout(r.show.bind(this), 800); tev = setTimeout(r.show.bind(this), 800);
if (TOUCH) if (TOUCH)