Merge pull request #25503 from acierto/clean-workspace-fix
Fixed the issue for cleaning the scaffolder workspace.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-backend': patch
|
||||
---
|
||||
|
||||
Found the issue during testing the clean up of the workspace for the database implementation.
|
||||
@@ -532,8 +532,8 @@ 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('tasks').where({ id: taskId }).update({
|
||||
workspace: null,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -542,10 +542,11 @@ export class DatabaseTaskStore implements TaskStore {
|
||||
taskId: string;
|
||||
}): Promise<void> {
|
||||
if (options.path) {
|
||||
const workspace = (await serializeWorkspace(options)).contents;
|
||||
await this.db<RawDbTaskRow>('tasks')
|
||||
.where({ id: options.taskId })
|
||||
.update({
|
||||
workspace: (await serializeWorkspace(options)).contents,
|
||||
workspace,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ export class DatabaseWorkspaceProvider implements WorkspaceProvider {
|
||||
path: string;
|
||||
taskId: string;
|
||||
}): Promise<void> {
|
||||
this.storage.serializeWorkspace?.(options);
|
||||
await this.storage.serializeWorkspace?.(options);
|
||||
}
|
||||
|
||||
public async rehydrateWorkspace(options: {
|
||||
|
||||
@@ -509,11 +509,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