mirror of
https://github.com/wukko/cobalt.git
synced 2025-06-03 08:29:24 +02:00
web/queue: remove final file from results without swapping for a dummy
This commit is contained in:
parent
9c16efd3b1
commit
2f6196f6e3
@ -6,15 +6,11 @@ import { clearCurrentTasks, removeWorkerFromQueue } from "$lib/state/task-manage
|
||||
|
||||
import type { CobaltQueue, CobaltQueueItem, CobaltQueueItemRunning, UUID } from "$lib/types/queue";
|
||||
|
||||
export const DUMMY_FILE = new File([], 'pipeline_result_deleted.bin');
|
||||
|
||||
const clearPipelineCache = (queueItem: CobaltQueueItem) => {
|
||||
if (queueItem.state === "running") {
|
||||
for (const [ workerId, item ] of Object.entries(queueItem.pipelineResults)) {
|
||||
if (item.name !== DUMMY_FILE.name) {
|
||||
removeFromFileStorage(item.name);
|
||||
queueItem.pipelineResults[workerId] = DUMMY_FILE;
|
||||
}
|
||||
removeFromFileStorage(item.name);
|
||||
delete queueItem.pipelineResults[workerId];
|
||||
}
|
||||
} else if (queueItem.state === "done") {
|
||||
removeFromFileStorage(queueItem.resultFile.name);
|
||||
|
@ -53,7 +53,9 @@ export const removeFromFileStorage = async (filename: string) => {
|
||||
try {
|
||||
const cobaltDir = await root.getDirectoryHandle(COBALT_PROCESSING_DIR);
|
||||
await cobaltDir.removeEntry(filename);
|
||||
} catch {}
|
||||
} catch {
|
||||
// catch and ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { get } from "svelte/store";
|
||||
import { startWorker } from "$lib/task-manager/run-worker";
|
||||
import { addWorkerToQueue, currentTasks } from "$lib/state/task-manager/current-tasks";
|
||||
import { DUMMY_FILE, itemDone, itemError, itemRunning, queue } from "$lib/state/task-manager/queue";
|
||||
import { itemDone, itemError, itemRunning, queue } from "$lib/state/task-manager/queue";
|
||||
|
||||
import type { CobaltPipelineItem } from "$lib/types/workers";
|
||||
|
||||
@ -28,10 +28,10 @@ export const schedule = () => {
|
||||
// if all workers are completed, then return the
|
||||
// the final file and go to the next task
|
||||
if (Object.keys(task.pipelineResults).length === task.pipeline.length) {
|
||||
// swap final file for a dummy, so that it doesn't get
|
||||
// deleted when we clean up the intermediate files
|
||||
// remove the final file from pipeline results, so that it doesn't
|
||||
// get deleted when we clean up the intermediate files
|
||||
const finalFile = task.pipelineResults[finalWorker.workerId];
|
||||
task.pipelineResults[finalWorker.workerId] = DUMMY_FILE;
|
||||
delete task.pipelineResults[finalWorker.workerId];
|
||||
|
||||
if (finalFile) {
|
||||
itemDone(task.id, finalFile);
|
||||
|
Loading…
x
Reference in New Issue
Block a user