From 8f5bae95ceeec970624c865e450d45d0e08228ac Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 7 Sep 2022 00:38:19 +0200 Subject: [PATCH] fix visual glitches in upload ui --- copyparty/web/browser.js | 2 -- copyparty/web/up2k.js | 19 ++++++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index aec7ea0e..63d81a5e 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -310,7 +310,6 @@ var Ls = { "u_etaprep": '(preparing to upload)', "u_hashdone": 'hashing done', "u_hashing": 'hash', - "u_upping": 'uploading', "u_fixed": "OK!  Fixed it 👍", "u_cuerr": "failed to upload chunk {0} of {1};\nprobably harmless, continuing\n\nfile: {2}", "u_cuerr2": "server rejected upload (chunk {0} of {1});\nwill retry later\n\nfile: {2}\n\nerror ", @@ -653,7 +652,6 @@ var Ls = { "u_etaprep": '(forbereder opplastning)', "u_hashdone": 'befaring ferdig', "u_hashing": 'les', - "u_upping": 'sender', "u_fixed": "OK!  Løste seg 👍", "u_cuerr": "kunne ikke laste opp del {0} av {1};\nsikkert harmløst, fortsetter\n\nfil: {2}", "u_cuerr2": "server nektet opplastningen (del {0} av {1});\nprøver igjen senere\n\nfil: {2}\n\nerror ", diff --git a/copyparty/web/up2k.js b/copyparty/web/up2k.js index f772d529..61be1cdb 100644 --- a/copyparty/web/up2k.js +++ b/copyparty/web/up2k.js @@ -267,6 +267,9 @@ function U2pvis(act, btns, uc, st) { fo.cb[nchunk] = cbd; fo.bd += delta; + if (!fo.bd) + return; + var p = r.perc(fo.bd, fo.bd0, fo.bt, fobj.t_uploading); fo.hp = f2f(p[0], 2) + '%, ' + p[1] + ', ' + f2f(p[2], 2) + ' MB/s'; @@ -2093,7 +2096,7 @@ function up2k_init(subtle) { 'npart': t.postlist[a] }); - msg = L.u_upping; + msg = null; done = false; if (sort) @@ -2103,7 +2106,10 @@ function up2k_init(subtle) { a.npart < b.npart ? -1 : 1; }); } - pvis.seth(t.n, 1, msg); + + if (msg) + pvis.seth(t.n, 1, msg); + apop(st.busy.handshake, t); if (done) { @@ -2207,7 +2213,14 @@ function up2k_init(subtle) { function can_upload_next() { var upt = st.todo.upload[0], - upf = st.files[upt.nfile]; + upf = st.files[upt.nfile], + now = Date.now(); + + for (var a = 0, aa = st.busy.handshake.length; a < aa; a++) { + var hs = st.busy.handshake[a]; + if (hs.n < upt.nfile && hs.t_busied > now - 10 * 1000 && !st.files[hs.n].bytes_uploaded) + return false; // handshake race; wait for lexically first + } if (upf.sprs) return true;