mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
fix(core): Copy metadata information for binary data when data is migrated using filesystem (no-changelog) (#16003)
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user