Fixed an issue for cleaning the scaffolder workspace.
Signed-off-by: bnechyporenko <bnechyporenko@bol.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user