Fix removing old tasks stopping the current render.

This commit is contained in:
Marc-Andre Ferland 2022-10-10 22:28:34 -04:00
parent 7060108a8b
commit 09b50badb1

View File

@ -637,23 +637,25 @@ async function checkTasks() {
const genSeeds = Boolean(typeof task.reqBody.seed !== 'number' || (task.reqBody.seed === task.seed && task.numOutputsTotal > 1)) const genSeeds = Boolean(typeof task.reqBody.seed !== 'number' || (task.reqBody.seed === task.seed && task.numOutputsTotal > 1))
const startSeed = task.reqBody.seed || task.seed const startSeed = task.reqBody.seed || task.seed
for (let i = 0; i < task.batchCount; i++) { for (let i = 0; i < task.batchCount; i++) {
let newTask = task;
if (task.batchCount > 1) { if (task.batchCount > 1) {
// Each output render batch needs it's own task instance to avoid altering the other runs after they are completed. // Each output render batch needs it's own task instance to avoid altering the other runs after they are completed.
task = Object.assign({}, task, { newTask = Object.assign({}, task, {
reqBody: Object.assign({}, task.reqBody) reqBody: Object.assign({}, task.reqBody)
}) })
} }
if (genSeeds) { if (genSeeds) {
task.reqBody.seed = startSeed + (i * task.reqBody.num_outputs) newTask.reqBody.seed = startSeed + (i * newTask.reqBody.num_outputs)
task.seed = task.reqBody.seed newTask.seed = newTask.reqBody.seed
} else if (task.seed !== task.reqBody.seed) { } else if (newTask.seed !== newTask.reqBody.seed) {
task.seed = task.reqBody.seed newTask.seed = newTask.reqBody.seed
} }
let success = await doMakeImage(task) let success = await doMakeImage(newTask)
task.batchesDone++ task.batchesDone++
if (!task.isProcessing) { if (!newTask.isProcessing) {
task.isProcessing = false
break break
} }