MCPcopy Create free account
hub / github.com/Noumena-Network/code / removeCronTasks

Function removeCronTasks

src/utils/cronTasks.ts:249–266  ·  view source on GitHub ↗
(
  ids: string[],
  dir?: string,
)

Source from the content-addressed store, hash-verified

247 * state on that path (tests enforce this).
248 */
249export async function removeCronTasks(
250 ids: string[],
251 dir?: string,
252): Promise<void> {
253 if (ids.length === 0) return
254 // Sweep session store first. If every id was accounted for there, we're
255 // done — skip the file read entirely. removeSessionCronTasks is a no-op
256 // (returns 0) on miss, so pre-existing durable-delete paths fall through
257 // without allocating.
258 if (dir === undefined && removeSessionCronTasks(ids) === ids.length) {
259 return
260 }
261 const idSet = new Set(ids)
262 const tasks = await readCronTasks(dir)
263 const remaining = tasks.filter(t => !idSet.has(t.id))
264 if (remaining.length === tasks.length) return
265 await writeCronTasks(remaining, dir)
266}
267
268/**
269 * Stamp `lastFiredAt` on the given recurring tasks and write back. Batched

Callers 4

callFunction · 0.85
loadFunction · 0.85
processFunction · 0.85
useScheduledTasksFunction · 0.85

Calls 4

removeSessionCronTasksFunction · 0.85
readCronTasksFunction · 0.85
writeCronTasksFunction · 0.85
hasMethod · 0.45

Tested by

no test coverage detected