diff --git a/copyparty/web/up2k.js b/copyparty/web/up2k.js index a05e414b..f645c6ce 100644 --- a/copyparty/web/up2k.js +++ b/copyparty/web/up2k.js @@ -21,6 +21,8 @@ var up2k = null, m = 'will use ' + sha_js + ' instead of native sha512 due to'; try { + if (sread('nosubtle') || window.nosubtle) + throw 'chickenbit'; var cf = crypto.subtle || crypto.webkitSubtle; cf.digest('SHA-512', new Uint8Array(1)).then( function (x) { console.log('sha-ok'); up2k = up2k_init(cf); }, @@ -1358,6 +1360,10 @@ function up2k_init(subtle) { for (var a = 0; a < Math.min(navigator.hardwareConcurrency || 4, 16); a++) hws.push(new Worker(SR + '/.cpr/w.hash.js?_=' + TS)); + if (!subtle) + for (var a = 0; a < hws.length; a++) + hws[a].postMessage('nosubtle'); + console.log(hws.length + " hashers"); } @@ -2579,7 +2585,7 @@ function up2k_init(subtle) { nparts = upt.nparts, pcar = nparts[0], pcdr = nparts[nparts.length - 1], - maxsz = u2sz_max * 1024 * 1024; + maxsz = (u2sz_max > 1 ? u2sz_max : 2040) * 1024 * 1024; if (t.done) return console.log('done; skip chunk', t.name, t); diff --git a/copyparty/web/w.hash.js b/copyparty/web/w.hash.js index 98b8f01e..559e5957 100644 --- a/copyparty/web/w.hash.js +++ b/copyparty/web/w.hash.js @@ -20,6 +20,7 @@ catch (ex) { function load_fb() { subtle = null; importScripts('deps/sha512.hw.js'); + console.log('using fallback hasher'); } @@ -29,6 +30,9 @@ var reader = null, onmessage = (d) => { + if (d.data == 'nosubtle') + return load_fb(); + if (busy) return postMessage(["panic", 'worker got another task while busy']);