Fixed an issue for cleaning the scaffolder workspace.

Signed-off-by: bnechyporenko <bnechyporenko@bol.com>
This commit is contained in:
bnechyporenko
2024-07-02 20:31:14 +02:00
parent 0f5c956bde
commit cae827a109
2 changed files with 12 additions and 8 deletions
@@ -527,8 +527,10 @@ export class DatabaseTaskStore implements TaskStore {
}
async cleanWorkspace({ taskId }: { taskId: string }): Promise<void> {
await this.db<RawDbTaskRow>('tasks').where({ id: taskId }).update({
workspace: undefined,
await this.db.transaction(async tx => {
await tx('tasks').where({ id: taskId }).update({
workspace: null,
});
});
}
@@ -537,11 +539,13 @@ export class DatabaseTaskStore implements TaskStore {
taskId: string;
}): Promise<void> {
if (options.path) {
await this.db<RawDbTaskRow>('tasks')
.where({ id: options.taskId })
.update({
workspace: (await serializeWorkspace(options)).contents,
});
await this.db.transaction(async tx => {
await tx<RawDbTaskRow>('tasks')
.where({ id: options.taskId })
.update({
workspace: (await serializeWorkspace(options)).contents,
});
});
}
}
@@ -508,11 +508,11 @@ export class NunjucksWorkflowRunner implements WorkflowRunner {
const output = this.render(task.spec.output, context, renderTemplate);
await taskTrack.markSuccessful();
await task.cleanWorkspace?.();
return { output };
} finally {
if (workspacePath) {
await task.cleanWorkspace?.();
await fs.remove(workspacePath);
}
}