From 5b26ab00961f008aff2023e1bd3b2f9931d7612e Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 28 Dec 2023 01:41:17 +0100 Subject: [PATCH] add option to specify default num parallel uploads --- copyparty/__main__.py | 1 + copyparty/httpcli.py | 1 + copyparty/web/browser.js | 2 +- copyparty/web/up2k.js | 10 +++++++--- copyparty/web/util.js | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/copyparty/__main__.py b/copyparty/__main__.py index d8937008..119cd7bf 100755 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -869,6 +869,7 @@ def add_upload(ap): ap2.add_argument("--df", metavar="GiB", type=float, default=0, help="ensure \033[33mGiB\033[0m free disk space by rejecting upload requests") ap2.add_argument("--sparse", metavar="MiB", type=int, default=4, help="windows-only: minimum size of incoming uploads through up2k before they are made into sparse files") ap2.add_argument("--turbo", metavar="LVL", type=int, default=0, help="configure turbo-mode in up2k client; [\033[32m-1\033[0m] = forbidden/always-off, [\033[32m0\033[0m] = default-off and warn if enabled, [\033[32m1\033[0m] = default-off, [\033[32m2\033[0m] = on, [\033[32m3\033[0m] = on and disable datecheck") + ap2.add_argument("--u2j", metavar="JOBS", type=int, default=2, help="web-client: number of file chunks to upload in parallel; 1 or 2 is good for low-latency (same-country) connections, 4-8 for android clients, 16-32 for cross-atlantic (max=64)") ap2.add_argument("--u2sort", metavar="TXT", type=u, default="s", help="upload order; [\033[32ms\033[0m]=smallest-first, [\033[32mn\033[0m]=alphabetical, [\033[32mfs\033[0m]=force-s, [\033[32mfn\033[0m]=force-n -- alphabetical is a bit slower on fiber/LAN but makes it easier to eyeball if everything went fine") ap2.add_argument("--write-uplog", action="store_true", help="write POST reports to textfiles in working-directory") diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 15eb703b..b8feda96 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -3966,6 +3966,7 @@ class HttpCli(object): "dsort": vf["sort"], "themes": self.args.themes, "turbolvl": self.args.turbo, + "u2j": self.args.u2j, "idxh": int(self.args.ih), "u2sort": self.args.u2sort, } diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index f49a017a..f152b152 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -1077,7 +1077,7 @@ ebi('op_up2k').innerHTML = ( ' \n' + ' \n' + ' +
 \n' + ' \n' + ' \n' + diff --git a/copyparty/web/up2k.js b/copyparty/web/up2k.js index 1917302c..1e43e074 100644 --- a/copyparty/web/up2k.js +++ b/copyparty/web/up2k.js @@ -852,7 +852,7 @@ function up2k_init(subtle) { setmsg(suggest_up2k, 'msg'); - var parallel_uploads = icfg_get('nthread'), + var parallel_uploads = ebi('nthread').value = icfg_get('nthread', u2j), uc = {}, fdom_ctr = 0, biggest_file = 0; @@ -2685,7 +2685,11 @@ function up2k_init(subtle) { } parallel_uploads = v; - swrite('nthread', v); + if (v == u2j) + localStorage.removeItem('nthread'); + else + swrite('nthread', v); + clmod(obj, 'err'); return; } @@ -2699,7 +2703,7 @@ function up2k_init(subtle) { parallel_uploads = 16; obj.value = parallel_uploads; - bumpthread({ "target": 1 }) + bumpthread({ "target": 1 }); } function tgl_fsearch() { diff --git a/copyparty/web/util.js b/copyparty/web/util.js index d830565a..593443b5 100644 --- a/copyparty/web/util.js +++ b/copyparty/web/util.js @@ -931,7 +931,7 @@ function fcfg_get(name, defval) { val = parseFloat(sread(name)); if (!isNum(val)) - return parseFloat(o ? o.value : defval); + return parseFloat(o && o.value !== '' ? o.value : defval); if (o) o.value = val;