mirror of
https://github.com/gchq/CyberChef
synced 2025-01-09 19:18:47 +00:00
Fix clear all button breaking everything.
Rearrange baking a bit to hopefully fix firefox
This commit is contained in:
parent
476d9c8034
commit
12e4fe4120
3 changed files with 60 additions and 23 deletions
|
@ -93,7 +93,10 @@ class InputWaiter {
|
||||||
});
|
});
|
||||||
this.inputWorker.postMessage({
|
this.inputWorker.postMessage({
|
||||||
action: "updateMaxTabs",
|
action: "updateMaxTabs",
|
||||||
data: this.maxTabs
|
data: {
|
||||||
|
maxTabs: this.maxTabs,
|
||||||
|
activeTab: this.getActiveTab()
|
||||||
|
}
|
||||||
});
|
});
|
||||||
this.inputWorker.postMessage({
|
this.inputWorker.postMessage({
|
||||||
action: "setLogLevel",
|
action: "setLogLevel",
|
||||||
|
@ -272,6 +275,9 @@ class InputWaiter {
|
||||||
case "queueInput":
|
case "queueInput":
|
||||||
this.manager.worker.queueInput(r.data);
|
this.manager.worker.queueInput(r.data);
|
||||||
break;
|
break;
|
||||||
|
case "queueInputError":
|
||||||
|
this.manager.worker.queueInputError(r.data);
|
||||||
|
break;
|
||||||
case "bakeAllInputs":
|
case "bakeAllInputs":
|
||||||
this.manager.worker.bakeAllInputs(r.data);
|
this.manager.worker.bakeAllInputs(r.data);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -188,8 +188,18 @@ self.bakeAllInputs = function() {
|
||||||
*/
|
*/
|
||||||
self.bakeInput = function(inputNum, bakeId) {
|
self.bakeInput = function(inputNum, bakeId) {
|
||||||
const inputObj = self.getInputObj(inputNum);
|
const inputObj = self.getInputObj(inputNum);
|
||||||
if (inputObj === null || inputObj === undefined) return;
|
if (inputObj === null ||
|
||||||
if (inputObj.status !== "loaded") return;
|
inputObj === undefined ||
|
||||||
|
inputObj.status !== "loaded") {
|
||||||
|
self.postMessage({
|
||||||
|
action: "queueInputError",
|
||||||
|
data: {
|
||||||
|
inputNum: inputNum,
|
||||||
|
bakeId: bakeId
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let inputData = inputObj.data;
|
let inputData = inputObj.data;
|
||||||
if (typeof inputData !== "string") inputData = inputData.fileBuffer;
|
if (typeof inputData !== "string") inputData = inputData.fileBuffer;
|
||||||
|
|
|
@ -472,6 +472,33 @@ class WorkerWaiter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles if an error is thrown by QueueInput
|
||||||
|
*
|
||||||
|
* @param {object} inputData
|
||||||
|
* @param {number} inputData.inputNum
|
||||||
|
* @param {number} inputData.bakeId
|
||||||
|
*/
|
||||||
|
queueInputError(inputData) {
|
||||||
|
this.loadingOutputs--;
|
||||||
|
if (this.app.baking && inputData.bakeId === this.bakeId) {
|
||||||
|
this.manager.output.updateOutputError("Error queueing the input for a bake.", inputData.inputNum, 0);
|
||||||
|
|
||||||
|
if (this.inputNums.length === 0) return;
|
||||||
|
|
||||||
|
// Load the next input
|
||||||
|
this.manager.input.inputWorker.postMessage({
|
||||||
|
action: "bakeNext",
|
||||||
|
data: {
|
||||||
|
inputNum: this.inputNums.splice(0, 1)[0],
|
||||||
|
bakeId: this.bakeId
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.loadingOutputs++;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queues a list of inputNums to be baked by ChefWorkers, and begins baking
|
* Queues a list of inputNums to be baked by ChefWorkers, and begins baking
|
||||||
*
|
*
|
||||||
|
@ -479,8 +506,8 @@ class WorkerWaiter {
|
||||||
* @param {number[]} inputData.nums
|
* @param {number[]} inputData.nums
|
||||||
* @param {boolean} inputData.step
|
* @param {boolean} inputData.step
|
||||||
*/
|
*/
|
||||||
bakeAllInputs(inputData) {
|
async bakeAllInputs(inputData) {
|
||||||
return new Promise(resolve => {
|
return await new Promise(resolve => {
|
||||||
if (this.app.baking) return;
|
if (this.app.baking) return;
|
||||||
const inputNums = inputData.nums;
|
const inputNums = inputData.nums;
|
||||||
const step = inputData.step;
|
const step = inputData.step;
|
||||||
|
@ -491,23 +518,22 @@ class WorkerWaiter {
|
||||||
this.inputNums = inputNums;
|
this.inputNums = inputNums;
|
||||||
this.totalOutputs = inputNums.length;
|
this.totalOutputs = inputNums.length;
|
||||||
|
|
||||||
let inactiveWorkers = 0;
|
for (let i = 0; i < inputNums.length; i++) {
|
||||||
for (let i = 0; i < this.chefWorkers.length; i++) {
|
if (this.addChefWorker() === -1) break;
|
||||||
if (!this.chefWorkers[i].active) {
|
|
||||||
inactiveWorkers++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let numWorkers = (inputNums.length > this.maxWorkers) ? this.maxWorkers : inputNums.length;
|
|
||||||
numWorkers -= inactiveWorkers;
|
|
||||||
|
|
||||||
for (let i = 0; i < numWorkers; i++) {
|
|
||||||
this.addChefWorker();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.app.bake(step);
|
this.app.bake(step);
|
||||||
|
|
||||||
for (let i = 0; i < numWorkers + inactiveWorkers; i++) {
|
for (let i = 0; i < this.inputNums.length; i++) {
|
||||||
|
this.manager.output.updateOutputMessage(`Input ${inputNums[i]} has not been baked yet.`, inputNums[i], false);
|
||||||
|
this.manager.output.updateOutputStatus("pending", inputNums[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
let numBakes = this.chefWorkers.length;
|
||||||
|
if (this.inputNums.length < numBakes) {
|
||||||
|
numBakes = this.inputNums.length;
|
||||||
|
}
|
||||||
|
for (let i = 0; i < numBakes; i++) {
|
||||||
this.manager.input.inputWorker.postMessage({
|
this.manager.input.inputWorker.postMessage({
|
||||||
action: "bakeNext",
|
action: "bakeNext",
|
||||||
data: {
|
data: {
|
||||||
|
@ -517,11 +543,6 @@ class WorkerWaiter {
|
||||||
});
|
});
|
||||||
this.loadingOutputs++;
|
this.loadingOutputs++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < this.inputNums.length; i++) {
|
|
||||||
this.manager.output.updateOutputMessage(`Input ${inputNums[i]} has not been baked yet.`, inputNums[i], false);
|
|
||||||
this.manager.output.updateOutputStatus("pending", inputNums[i]);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue