add potato mode

This commit is contained in:
ed 2022-07-14 02:33:35 +02:00
parent 48b957f1d5
commit c2b66bbe73
7 changed files with 88 additions and 11 deletions

View file

@ -1130,7 +1130,7 @@ class HttpCli(object):
cinf = self.headers.get("x-up2k-stat", "")
spd = self._spd(post_sz)
self.log("{} thank {}".format(spd, cinf))
self.log("{:70} thank {}".format(spd, cinf))
self.reply(b"thank")
return True

View file

@ -2216,6 +2216,10 @@ html.y #bbox-overlay figcaption a {
#u2notbtn * {
line-height: 1.3em;
}
#u2mu div {
height: 1.2em;
overflow: hidden;
}
#u2tabw {
min-height: 0;
transition: min-height .2s;
@ -2225,6 +2229,7 @@ html.y #bbox-overlay figcaption a {
display: none;
}
#u2tab {
table-layout: fixed;
border-collapse: collapse;
width: calc(100% - 2em);
max-width: 100em;
@ -2348,7 +2353,7 @@ html.y #bbox-overlay figcaption a {
width: 48em;
}
#u2conf.ww {
width: 74em;
width: 78em;
}
#u2conf.ww #u2c3w {
width: 29em;

View file

@ -63,6 +63,7 @@ var Ls = {
"ul_par": "parallel uploads:",
"ut_mt": "continue hashing other files while uploading$N$Nmaybe disable if your CPU or HDD is a bottleneck",
"ut_ask": "ask for confirmation before upload starts",
"ut_pot": "improve upload speed on slow devices$Nby making the UI less complex",
"ut_srch": "don't actually upload, instead check if the files already $N exist on the server (will scan all folders you can read)",
"ut_par": "pause uploads by setting it to 0$N$Nincrease if your connection is slow / high latency$N$Nkeep it 1 on LAN or if the server HDD is a bottleneck",
"ul_btn": "drop files / folders<br>here (or click me)",
@ -390,6 +391,7 @@ var Ls = {
"ul_par": "samtidige handl.:",
"ut_mt": "fortsett å befare køen mens opplastning foregår$N$Nskru denne av dersom du har en$Ntreg prosessor eller harddisk",
"ut_ask": "bekreft filutvalg før opplastning starter",
"ut_pot": "forbedre ytelsen på trege enheter ved å$Nforenkle brukergrensesnittet",
"ut_srch": "utfør søk istedenfor å laste opp --$Nleter igjennom alle mappene du har lov til å se",
"ut_par": "sett til 0 for å midlertidig stanse opplastning$N$Nhøye verdier (4 eller 8) kan gi bedre ytelse,$Nspesielt på trege internettlinjer$N$Nbør ikke være høyere enn 1 på LAN$Neller hvis serveren sin harddisk er treg",
"ul_btn": "slipp filer / mapper<br>her (eller klikk meg)",
@ -721,6 +723,10 @@ ebi('op_up2k').innerHTML = (
' <label for="multitask" tt="' + L.ut_mt + '">🏃</label>\n' +
' </td>\n' +
' <td class="c" rowspan="2">\n' +
' <input type="checkbox" id="potato" />\n' +
' <label for="potato" tt="' + L.ut_pot + '">🥔</label>\n' +
' </td>\n' +
' <td class="c" rowspan="2">\n' +
' <input type="checkbox" id="ask_up" />\n' +
' <label for="ask_up" tt="' + L.ut_ask + '">💭</label>\n' +
' </td>\n' +
@ -776,7 +782,7 @@ ebi('op_up2k').innerHTML = (
' </tr>\n' +
' </thead>\n' +
' <tbody></tbody>\n' +
'</table></div>\n' +
'</table><div id="u2mu"></div></div>\n' +
'<p id="u2flagblock"><b>' + L.ul_flagblk + '</p>\n' +
'<p id="u2foot"></p>'

View file

@ -144,6 +144,7 @@ function U2pvis(act, btns, uc) {
r.head = 0;
r.tail = -1;
r.wsz = 3;
r.npotato = 99;
var markup = {
'404': '<span class="err">404</span>',
@ -181,6 +182,9 @@ function U2pvis(act, btns, uc) {
};
r.is_act = function (card) {
if (uc.potato && !uc.fsearch)
return false;
if (r.act == "done")
return card == "ok" || card == "ng";
@ -361,6 +365,38 @@ function U2pvis(act, btns, uc) {
}
};
r.potato = function () {
QS('#u2cards a[act="bz"]').click();
timer[uc.potato ? "add" : "rm"](draw_potato);
};
function draw_potato() {
if (++r.npotato < 2)
return;
r.npotato = 0;
var html = [
"<p>files: &nbsp; <b>{0}</b> finished, &nbsp; <b>{1}</b> failed, &nbsp; <b>{2}</b> busy, &nbsp; <b>{3}</b> queued</p>".format(r.ctr.ok, r.ctr.ng, r.ctr.bz, r.ctr.q),
];
while (r.head < r.tab.length && has(["ok", "ng"], r.tab[r.head].in))
r.head++;
var act = null;
if (r.head < r.tab.length)
act = r.tab[r.head];
if (act)
html.push("<p>file {0} of {1} : &nbsp; {2} &nbsp; <code>{3}</code></p>\n<div>{4}</div>".format(r.head + 1, r.tab.length, act.ht, act.hp, act.hn));
html = html.join('\n');
if (r.hpotato == html)
return;
r.hpotato = html;
ebi('u2mu').innerHTML = html;
}
r.drawcard = function (cat) {
var cards = QSA('#u2cards>a>span');
@ -477,6 +513,7 @@ function U2pvis(act, btns, uc) {
}
r.changecard(r.act);
r.potato();
}
@ -528,7 +565,7 @@ function Donut(uc, st) {
}
r.on = function (ya) {
r.fc = r.tc = 99;
r.fc = r.tc = r.dc = 99;
r.eta = null;
r.base = pos();
optab.innerHTML = ya ? svg() : optab.getAttribute('ico');
@ -544,10 +581,16 @@ function Donut(uc, st) {
var t = st.bytes.total - r.base,
v = pos() - r.base,
ofs = el.style.strokeDashoffset = o - o * v / t;
ofs = o - o * v / t;
if (!uc.potato || ++r.dc >= 2) {
el.style.strokeDashoffset = ofs;
r.dc = 0;
}
if (++r.tc >= 10) {
wintitle(f2f(v * 100 / t, 1) + '%, ' + r.eta + 's, ', true);
wintitle("{0}%, {1}s, #{2}, ".format(
f2f(v * 100 / t, 1), r.eta, st.files.length - st.nfile.upload), true);
r.tc = 0;
}
@ -658,6 +701,7 @@ function up2k_init(subtle) {
biggest_file = 0;
bcfg_bind(uc, 'multitask', 'multitask', true, null, false);
bcfg_bind(uc, 'potato', 'potato', false, set_potato, false);
bcfg_bind(uc, 'ask_up', 'ask_up', true, null, false);
bcfg_bind(uc, 'flag_en', 'flag_en', false, apply_flag_cfg);
bcfg_bind(uc, 'fsearch', 'fsearch', false, set_fsearch, false);
@ -667,6 +711,10 @@ function up2k_init(subtle) {
var st = {
"files": [],
"nfile": {
"hash": 0,
"upload": 0
},
"seen": {},
"todo": {
"head": [],
@ -1461,6 +1509,7 @@ function up2k_init(subtle) {
function exec_hash() {
var t = st.todo.hash.shift();
st.busy.hash.push(t);
st.nfile.hash = t.n;
var bpend = 0,
nchunk = 0,
@ -1877,6 +1926,7 @@ function up2k_init(subtle) {
function exec_upload() {
var upt = st.todo.upload.shift();
st.busy.upload.push(upt);
st.nfile.upload = upt.nfile;
var npart = upt.npart,
t = st.files[upt.nfile],
@ -1980,7 +2030,7 @@ function up2k_init(subtle) {
ebi('u2conf').className = ebi('u2cards').className = ebi('u2etaw').className = wide;
}
wide = write && wem > 78 ? 'ww' : wide;
wide = write && wem > 82 ? 'ww' : wide;
parent = ebi(wide == 'ww' && write ? 'u2c3w' : 'u2c3t');
var its = [ebi('u2etaw'), ebi('u2cards')];
if (its[0].parentNode !== parent) {
@ -2072,6 +2122,11 @@ function up2k_init(subtle) {
}
draw_turbo();
function set_potato() {
pvis.potato();
set_fsearch();
}
function set_fsearch(new_state) {
var fixed = false;
@ -2110,6 +2165,10 @@ function up2k_init(subtle) {
ebi('u2tab').className = (uc.fsearch ? 'srch ' : 'up ') + pvis.act;
var potato = uc.potato && !uc.fsearch;
ebi('u2cards').style.display = ebi('u2tab').style.display = potato ? 'none' : '';
ebi('u2mu').style.display = potato ? '' : 'none';
draw_turbo();
onresize();
}

View file

@ -1186,7 +1186,8 @@ var modal = (function () {
return;
setTimeout(function () {
ebi('modal-ok').focus();
if (ctr = ebi('modal-ok'))
ctr.focus();
}, 20);
ev(e);
}

View file

@ -50,6 +50,9 @@ avg() { awk 'function pr(ncsz) {if (nsmp>0) {printf "%3s %s\n", csz, sum/nsmp} c
python3 -um copyparty -nw -v srv::rw -i 127.0.0.1 2>&1 | tee log
cat log | awk '!/"purl"/{next} {s=$1;sub(/[^m]+m/,"");gsub(/:/," ");t=60*(60*$1+$2)+$3} !a{a=t;sa=s} {b=t;sb=s} END {print b-a,sa,sb}'
# or if the client youre measuring dies for ~15sec every once ina while and you wanna filter those out,
cat log | awk '!/"purl"/{next} {s=$1;sub(/[^m]+m/,"");gsub(/:/," ");t=60*(60*$1+$2)+$3} !p{a=t;p=t;r=0;next} t-p>1{printf "%.3f += %.3f - %.3f (%.3f) # %.3f -> %.3f\n",r,p,a,p-a,p,t;r+=p-a;a=t} {p=t} END {print r+p-a}'
##
## bad filenames

View file

@ -22,13 +22,16 @@ v=$1
}
rm -f ../dist/copyparty-sfx.*
shift
./make-sfx.sh "$@"
f=../dist/copyparty-sfx.py
./make-sfx.sh
$f -h
[ -e $f ] ||
f=../dist/copyparty-sfx-gz.py
$f -h
while true; do
mv $f $f.$(wc -c <$f | awk '{print$1}')
./make-sfx.sh re $ar
./make-sfx.sh re "$@"
done
# git tag -d v$v; git push --delete origin v$v