VideoChain-API / src /scheduler /updatePendingTask.mts
jbilcke-hf's picture
jbilcke-hf HF staff
ok! now, time to debug and build the frontend..
5dfc565
raw
history blame
695 Bytes
import { promises as fs } from "node:fs"
import path from "path"
import { VideoTask } from "../types.mts"
import { pendingTasksDirFilePath } from "../config.mts"
export const updatePendingTask = async (task: VideoTask) => {
try {
const fileName = `${task.id}.json`
const filePath = path.join(pendingTasksDirFilePath, fileName)
await fs.writeFile(filePath, JSON.stringify(task, null, 2), "utf8")
} catch (err) {
console.error(`Failed to update the task. Probably an issue with the serialized object or the file system: ${err}`)
// we do not forward the exception, there is no need
// we will just try again the job later (even if it means losing a bit of data)
}
}