mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 09:22:31 -06:00
up2k-client: way faster init on large filedrops
This commit is contained in:
parent
664f53b75d
commit
56522599b5
|
@ -142,7 +142,7 @@ function U2pvis(act, btns) {
|
||||||
this.tail = -1;
|
this.tail = -1;
|
||||||
this.wsz = 3;
|
this.wsz = 3;
|
||||||
|
|
||||||
this.addfile = function (entry, sz) {
|
this.addfile = function (entry, sz, draw) {
|
||||||
this.tab.push({
|
this.tab.push({
|
||||||
"hn": entry[0],
|
"hn": entry[0],
|
||||||
"ht": entry[1],
|
"ht": entry[1],
|
||||||
|
@ -156,6 +156,9 @@ function U2pvis(act, btns) {
|
||||||
"bd0": 0 // upload start
|
"bd0": 0 // upload start
|
||||||
});
|
});
|
||||||
this.ctr["q"]++;
|
this.ctr["q"]++;
|
||||||
|
if (!draw)
|
||||||
|
return;
|
||||||
|
|
||||||
this.drawcard("q");
|
this.drawcard("q");
|
||||||
if (this.act == "q") {
|
if (this.act == "q") {
|
||||||
this.addrow(this.tab.length - 1);
|
this.addrow(this.tab.length - 1);
|
||||||
|
@ -350,8 +353,21 @@ function U2pvis(act, btns) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.head == -1) {
|
if (this.head == -1) {
|
||||||
this.head = this.tab.length;
|
var precard = has(["ok", "ng", "done"], this.act) ? {} : this.act == "bz" ? { "ok": 1, "ng": 1 } : { "ok": 1, "ng": 1, "bz": 1 },
|
||||||
this.tail = this.head - 1;
|
postcard = has(["ok", "ng", "done"], this.act) ? { "bz": 1, "q": 1 } : this.act == "bz" ? { "q": 1 } : {};
|
||||||
|
|
||||||
|
for (var a = 0; a < this.tab.length; a++) {
|
||||||
|
var rt = this.tab[a].in;
|
||||||
|
if (precard[rt]) {
|
||||||
|
this.head = a + 1;
|
||||||
|
this.tail = a;
|
||||||
|
}
|
||||||
|
else if (postcard[rt]) {
|
||||||
|
this.head = a;
|
||||||
|
this.tail = a - 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (card == "bz") {
|
if (card == "bz") {
|
||||||
for (var a = this.head - 1; a >= this.head - this.wsz && a >= 0; a--) {
|
for (var a = this.head - 1; a >= this.head - this.wsz && a >= 0; a--) {
|
||||||
|
@ -706,41 +722,50 @@ function up2k_init(subtle) {
|
||||||
if (ask_up && !fsearch && !confirm(msg.join('\n')))
|
if (ask_up && !fsearch && !confirm(msg.join('\n')))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
var seen = {},
|
||||||
|
evpath = get_evpath(),
|
||||||
|
draw_each = good_files.length < 50;
|
||||||
|
|
||||||
|
for (var a = 0; a < st.files.length; a++)
|
||||||
|
seen[st.files[a].name + '\n' + st.files[a].size] = 1;
|
||||||
|
|
||||||
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],
|
||||||
now = Date.now(),
|
now = Date.now(),
|
||||||
lmod = fobj.lastModified || now;
|
lmod = fobj.lastModified || now;
|
||||||
|
|
||||||
var entry = {
|
var entry = {
|
||||||
"n": parseInt(st.files.length.toString()),
|
"n": st.files.length,
|
||||||
"t0": now,
|
"t0": now,
|
||||||
"fobj": fobj,
|
"fobj": fobj,
|
||||||
"name": good_files[a][1],
|
"name": good_files[a][1],
|
||||||
"size": fobj.size,
|
"size": fobj.size,
|
||||||
"lmod": lmod / 1000,
|
"lmod": lmod / 1000,
|
||||||
"purl": get_evpath(),
|
"purl": evpath,
|
||||||
"done": false,
|
"done": false,
|
||||||
"hash": []
|
"hash": []
|
||||||
};
|
},
|
||||||
|
key = entry.name + '\n' + entry.size;
|
||||||
|
|
||||||
var skip = false;
|
if (seen[key])
|
||||||
for (var b = 0; b < st.files.length; b++)
|
|
||||||
if (entry.name == st.files[b].name &&
|
|
||||||
entry.size == st.files[b].size)
|
|
||||||
skip = true;
|
|
||||||
|
|
||||||
if (skip)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
seen[key] = 1;
|
||||||
|
|
||||||
pvis.addfile([
|
pvis.addfile([
|
||||||
fsearch ? esc(entry.name) : linksplit(
|
fsearch ? esc(entry.name) : linksplit(
|
||||||
uricom_dec(entry.purl)[0] + entry.name).join(' '),
|
uricom_dec(entry.purl)[0] + entry.name).join(' '),
|
||||||
'📐 hash',
|
'📐 hash',
|
||||||
''
|
''
|
||||||
], fobj.size);
|
], fobj.size, draw_each);
|
||||||
|
|
||||||
st.files.push(entry);
|
st.files.push(entry);
|
||||||
st.todo.hash.push(entry);
|
st.todo.hash.push(entry);
|
||||||
}
|
}
|
||||||
|
if (!draw_each) {
|
||||||
|
pvis.drawcard("q");
|
||||||
|
pvis.changecard(pvis.act);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ebi('u2btn').addEventListener('drop', gotfile, false);
|
ebi('u2btn').addEventListener('drop', gotfile, false);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue