Skip to content

Commit

Permalink
fix(core): Delete binary data parent folder when pruning executions (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
netroy authored Nov 19, 2024
1 parent 91f9390 commit 17ef2c6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/core/src/BinaryData/FileSystem.manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class FileSystemManager implements BinaryData.Manager {
// binary files stored in nested dirs - `filesystem-v2`

const binaryDataDirs = ids.map(({ workflowId, executionId }) =>
this.resolvePath(`workflows/${workflowId}/executions/${executionId}/binary_data/`),
this.resolvePath(`workflows/${workflowId}/executions/${executionId}`),
);

await Promise.all(
Expand Down
15 changes: 15 additions & 0 deletions packages/core/test/FileSystem.manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ describe('copyByFilePath()', () => {
});

describe('deleteMany()', () => {
const rmOptions = {
force: true,
recursive: true,
};

it('should delete many files by workflow ID and execution ID', async () => {
const ids = [
{ workflowId, executionId },
Expand All @@ -160,6 +165,16 @@ describe('deleteMany()', () => {
await expect(promise).resolves.not.toThrow();

expect(fsp.rm).toHaveBeenCalledTimes(2);
expect(fsp.rm).toHaveBeenNthCalledWith(
1,
`${storagePath}/workflows/${workflowId}/executions/${executionId}`,
rmOptions,
);
expect(fsp.rm).toHaveBeenNthCalledWith(
2,
`${storagePath}/workflows/${otherWorkflowId}/executions/${otherExecutionId}`,
rmOptions,
);
});

it('should suppress error on non-existing filepath', async () => {
Expand Down

0 comments on commit 17ef2c6

Please sign in to comment.