fix non-e2d dupe finalizing;

when the up2k database is not enabled, only the
38400 most recent uploads are kept in memory serverside

the webui did not anticipate this, expecting the server to
finalize all dupes with just a single pass of brief handshakes

fix this by doing as many passes as necessary, only stopping if
a pass does not make any progress (filesystem-issues or some such)
This commit is contained in:
ed 2025-08-07 15:57:51 +00:00
parent 8a0746c6af
commit 4a04356814

View file

@ -964,6 +964,7 @@ function up2k_init(subtle) {
"t": 0 "t": 0
}, },
"car": 0, "car": 0,
"nre": 0,
"slow_io": null, "slow_io": null,
"oserr": false, "oserr": false,
"modn": 0, "modn": 0,
@ -1783,8 +1784,7 @@ function up2k_init(subtle) {
} }
var tasker = (function () { var tasker = (function () {
var running = false, var running = false;
was_busy = false;
var defer = function () { var defer = function () {
running = false; running = false;
@ -1801,7 +1801,17 @@ function up2k_init(subtle) {
while (true) { while (true) {
var now = Date.now(), var now = Date.now(),
blocktime = now - r.tact, blocktime = now - r.tact,
is_busy = st.car < st.files.length; was_busy = st.is_busy,
is_busy = !!( // gzip take the wheel
st.car < st.files.length ||
st.busy.hash.length ||
st.todo.hash.length ||
st.busy.handshake.length ||
st.todo.handshake.length ||
st.busy.upload.length ||
st.todo.upload.length ||
st.busy.head.length ||
st.todo.head.length);
if (blocktime > 2500) if (blocktime > 2500)
console.log('main thread blocked for ' + blocktime); console.log('main thread blocked for ' + blocktime);
@ -1809,7 +1819,16 @@ function up2k_init(subtle) {
r.tact = now; r.tact = now;
if (was_busy && !is_busy) { if (was_busy && !is_busy) {
for (var a = 0; a < st.files.length; a++) { var nre = 0, nf = 0;
for (var a = 0; a < st.files.length; a++)
if (st.files[a].want_recheck)
nre++;
console.log('nre', nre, 'st', st.nre);
if (st.nre != nre) {
st.nre = nre;
nf = st.files.length;
}
for (var a = 0; a < nf; a++) {
var t = st.files[a]; var t = st.files[a];
if (t.want_recheck) { if (t.want_recheck) {
t.rechecks++; t.rechecks++;
@ -1817,7 +1836,7 @@ function up2k_init(subtle) {
push_t(st.todo.handshake, t); push_t(st.todo.handshake, t);
} }
} }
is_busy = st.todo.handshake.length; is_busy = !!st.todo.handshake.length;
try { try {
if (!is_busy && !uc.fsearch && !msel.getsel().length && (!mp.au || mp.au.paused)) if (!is_busy && !uc.fsearch && !msel.getsel().length && (!mp.au || mp.au.paused))
treectl.goto(); treectl.goto();
@ -1826,7 +1845,7 @@ function up2k_init(subtle) {
} }
if (was_busy != is_busy) { if (was_busy != is_busy) {
st.is_busy = was_busy = is_busy; st.is_busy = is_busy;
window[(is_busy ? "add" : "remove") + window[(is_busy ? "add" : "remove") +
"EventListener"]("beforeunload", warn_uploader_busy); "EventListener"]("beforeunload", warn_uploader_busy);
@ -1947,7 +1966,7 @@ function up2k_init(subtle) {
for (var a = 0; a < st.files.length; a++) { for (var a = 0; a < st.files.length; a++) {
var t = st.files[a]; var t = st.files[a];
if (t.want_recheck && !t.rechecks) if (t.want_recheck && t.rechecks < 999)
return; return;
} }
@ -2693,8 +2712,9 @@ function up2k_init(subtle) {
if (ofs !== -1) { if (ofs !== -1) {
err = err.slice(0, ofs + 1) + linksplit(err.slice(ofs + 2).trimEnd()).join(' / '); err = err.slice(0, ofs + 1) + linksplit(err.slice(ofs + 2).trimEnd()).join(' / ');
} }
if (!t.rechecks && (err_pend || err_srcb)) { if (!t.rechecks)
t.rechecks = 0; t.rechecks = 0;
if (t.rechecks < 999 && (err_pend || err_srcb)) {
t.want_recheck = true; t.want_recheck = true;
if (st.busy.upload.length || st.busy.handshake.length || st.bytes.uploaded) { if (st.busy.upload.length || st.busy.handshake.length || st.bytes.uploaded) {
err = L.u_dupdefer; err = L.u_dupdefer;