( ids: string[], dir?: string, )
| 247 | * state on that path (tests enforce this). |
| 248 | */ |
| 249 | export 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 |
no test coverage detected