mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
add chickenbit to force hashwasm
This commit is contained in:
parent
fc8298c468
commit
d715479ef6
|
@ -21,6 +21,8 @@ var up2k = null,
|
||||||
m = 'will use ' + sha_js + ' instead of native sha512 due to';
|
m = 'will use ' + sha_js + ' instead of native sha512 due to';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (sread('nosubtle') || window.nosubtle)
|
||||||
|
throw 'chickenbit';
|
||||||
var cf = crypto.subtle || crypto.webkitSubtle;
|
var cf = crypto.subtle || crypto.webkitSubtle;
|
||||||
cf.digest('SHA-512', new Uint8Array(1)).then(
|
cf.digest('SHA-512', new Uint8Array(1)).then(
|
||||||
function (x) { console.log('sha-ok'); up2k = up2k_init(cf); },
|
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++)
|
for (var a = 0; a < Math.min(navigator.hardwareConcurrency || 4, 16); a++)
|
||||||
hws.push(new Worker(SR + '/.cpr/w.hash.js?_=' + TS));
|
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");
|
console.log(hws.length + " hashers");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2579,7 +2585,7 @@ function up2k_init(subtle) {
|
||||||
nparts = upt.nparts,
|
nparts = upt.nparts,
|
||||||
pcar = nparts[0],
|
pcar = nparts[0],
|
||||||
pcdr = nparts[nparts.length - 1],
|
pcdr = nparts[nparts.length - 1],
|
||||||
maxsz = u2sz_max * 1024 * 1024;
|
maxsz = (u2sz_max > 1 ? u2sz_max : 2040) * 1024 * 1024;
|
||||||
|
|
||||||
if (t.done)
|
if (t.done)
|
||||||
return console.log('done; skip chunk', t.name, t);
|
return console.log('done; skip chunk', t.name, t);
|
||||||
|
|
|
@ -20,6 +20,7 @@ catch (ex) {
|
||||||
function load_fb() {
|
function load_fb() {
|
||||||
subtle = null;
|
subtle = null;
|
||||||
importScripts('deps/sha512.hw.js');
|
importScripts('deps/sha512.hw.js');
|
||||||
|
console.log('using fallback hasher');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,6 +30,9 @@ var reader = null,
|
||||||
|
|
||||||
|
|
||||||
onmessage = (d) => {
|
onmessage = (d) => {
|
||||||
|
if (d.data == 'nosubtle')
|
||||||
|
return load_fb();
|
||||||
|
|
||||||
if (busy)
|
if (busy)
|
||||||
return postMessage(["panic", 'worker got another task while busy']);
|
return postMessage(["panic", 'worker got another task while busy']);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue