fix(core): Copy metadata information for binary data when data is migrated using filesystem (no-changelog) (#16003)

This commit is contained in:
Andreas Fitzek
2025-06-04 14:52:15 +02:00
committed by GitHub
parent 9abb333507
commit 40de4ed91c
2 changed files with 7 additions and 0 deletions

View File

@@ -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);
});
});

View File

@@ -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;
}