mirror of
https://github.com/gchq/CyberChef
synced 2025-01-08 10:38:46 +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({
|
||||
action: "updateMaxTabs",
|
||||
data: this.maxTabs
|
||||
data: {
|
||||
maxTabs: this.maxTabs,
|
||||
activeTab: this.getActiveTab()
|
||||
}
|
||||
});
|
||||
this.inputWorker.postMessage({
|
||||
action: "setLogLevel",
|
||||
|
@ -272,6 +275,9 @@ class InputWaiter {
|
|||
case "queueInput":
|
||||
this.manager.worker.queueInput(r.data);
|
||||
break;
|
||||
case "queueInputError":
|
||||
this.manager.worker.queueInputError(r.data);
|
||||
break;
|
||||
case "bakeAllInputs":
|
||||
this.manager.worker.bakeAllInputs(r.data);
|
||||
break;
|
||||
|
|
|
@ -188,8 +188,18 @@ self.bakeAllInputs = function() {
|
|||
*/
|
||||
self.bakeInput = function(inputNum, bakeId) {
|
||||
const inputObj = self.getInputObj(inputNum);
|
||||
if (inputObj === null || inputObj === undefined) return;
|
||||
if (inputObj.status !== "loaded") return;
|
||||
if (inputObj === null ||
|
||||
inputObj === undefined ||
|
||||
inputObj.status !== "loaded") {
|
||||
self.postMessage({
|
||||
action: "queueInputError",
|
||||
data: {
|
||||
inputNum: inputNum,
|
||||
bakeId: bakeId
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let inputData = inputObj.data;
|
||||
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
|
||||
*
|
||||
|
@ -479,8 +506,8 @@ class WorkerWaiter {
|
|||
* @param {number[]} inputData.nums
|
||||
* @param {boolean} inputData.step
|
||||
*/
|
||||
bakeAllInputs(inputData) {
|
||||
return new Promise(resolve => {
|
||||
async bakeAllInputs(inputData) {
|
||||
return await new Promise(resolve => {
|
||||
if (this.app.baking) return;
|
||||
const inputNums = inputData.nums;
|
||||
const step = inputData.step;
|
||||
|
@ -491,23 +518,22 @@ class WorkerWaiter {
|
|||
this.inputNums = inputNums;
|
||||
this.totalOutputs = inputNums.length;
|
||||
|
||||
let inactiveWorkers = 0;
|
||||
for (let i = 0; i < this.chefWorkers.length; i++) {
|
||||
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();
|
||||
for (let i = 0; i < inputNums.length; i++) {
|
||||
if (this.addChefWorker() === -1) break;
|
||||
}
|
||||
|
||||
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({
|
||||
action: "bakeNext",
|
||||
data: {
|
||||
|
@ -517,11 +543,6 @@ class WorkerWaiter {
|
|||
});
|
||||
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