fix(db): move active runs query into deleteTask transaction (P1-12 TOCTOU)
This commit is contained in:
1 parent
9874d825b6
commit
2eb6cb2c06
1 file changed
+9
-9
@@ -116,16 +116,16 @@ export function buildTaskCrudMethods(
|
||||
},
|
||||
|
||||
deleteTask(id: string, companyId: string): void {
|
||||
const activeTaskRuns = readAll<{
|
||||
id: string;
|
||||
taskId: string;
|
||||
workspaceId: string | null;
|
||||
}>(
|
||||
"select id, task_id as taskId, workspace_id as workspaceId from runs where task_id = ? and company_id = ? and status in ('queued', 'running')",
|
||||
id,
|
||||
companyId,
|
||||
);
|
||||
transaction(() => {
|
||||
const activeTaskRuns = getDb()
|
||||
.prepare(
|
||||
"select id, task_id as taskId, workspace_id as workspaceId from runs where task_id = ? and company_id = ? and status in ('queued', 'running')",
|
||||
)
|
||||
.all(id, companyId) as Array<{
|
||||
id: string;
|
||||
taskId: string;
|
||||
workspaceId: string | null;
|
||||
}>;
|
||||
for (const run of activeTaskRuns) {
|
||||
const ts = nowIso();
|
||||
getDb()
|
||||
|
||||
Reference in new issue
Block a user