From 40de4ed91c00fa366c131363363729592d1ab57a Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Wed, 4 Jun 2025 14:52:15 +0200 Subject: [PATCH] fix(core): Copy metadata information for binary data when data is migrated using filesystem (no-changelog) (#16003) --- .../src/binary-data/__tests__/file-system.manager.test.ts | 4 ++++ packages/core/src/binary-data/file-system.manager.ts | 3 +++ 2 files changed, 7 insertions(+) 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; }