diff --git a/packages/core/src/binary-data/__tests__/file-system.manager.test.ts b/packages/core/src/binary-data/__tests__/file-system.manager.test.ts index 19fa867b41c..8f72dac38fb 100644 --- a/packages/core/src/binary-data/__tests__/file-system.manager.test.ts +++ b/packages/core/src/binary-data/__tests__/file-system.manager.test.ts @@ -99,6 +99,7 @@ describe('getMetadata()', () => { describe('copyByFileId()', () => { it('should copy by file ID and return the file ID', async () => { fsp.copyFile = jest.fn().mockResolvedValue(undefined); + fsp.writeFile = jest.fn().mockResolvedValue(undefined); // @ts-expect-error - private method jest.spyOn(fsManager, 'toFileId').mockReturnValue(otherFileId); @@ -109,6 +110,9 @@ describe('copyByFileId()', () => { const targetPath = toFullFilePath(targetFileId); expect(fsp.copyFile).toHaveBeenCalledWith(sourcePath, targetPath); + + // Make sure metadata file was written + expect(fsp.writeFile).toBeCalledTimes(1); }); }); diff --git a/packages/core/src/binary-data/file-system.manager.ts b/packages/core/src/binary-data/file-system.manager.ts index 66eecd626a7..a951e98cd42 100644 --- a/packages/core/src/binary-data/file-system.manager.ts +++ b/packages/core/src/binary-data/file-system.manager.ts @@ -127,11 +127,14 @@ export class FileSystemManager implements BinaryData.Manager { const targetFileId = this.toFileId(workflowId, executionId); const sourcePath = this.resolvePath(sourceFileId); const targetPath = this.resolvePath(targetFileId); + const sourceMetadata = await this.getMetadata(sourceFileId); await assertDir(path.dirname(targetPath)); await fs.copyFile(sourcePath, targetPath); + await this.storeMetadata(targetFileId, sourceMetadata); + return targetFileId; }