mirror of
https://github.com/n8n-io/n8n.git
synced 2026-06-01 09:17:08 +02:00
fix(core): Copy metadata information for binary data when data is migrated using filesystem (no-changelog) (#16003)
This commit is contained in:
parent
9abb333507
commit
40de4ed91c
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user