mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor(core): Consolidate binary file not found errors (no-changelog) (#7585)
Logging was originally to see if there was a binary data file failing to be written for [this user](https://linear.app/n8n/issue/PAY-844/filesystem-binary-data-mode-causing-alerts-in-cloud) but the cause was not a file failed to be written but a missing `fileId` in a binary data item in an execution. The error should no longer be thrown as of 1.12. See story for more info. This PR is for cleanup and to consolidate any file not found errors in the context of binary data, to track if this happens again.
This commit is contained in:
@@ -53,6 +53,7 @@ describe('getPath()', () => {
|
||||
describe('getAsBuffer()', () => {
|
||||
it('should return a buffer', async () => {
|
||||
fsp.readFile = jest.fn().mockResolvedValue(mockBuffer);
|
||||
fsp.access = jest.fn().mockImplementation(async () => {});
|
||||
|
||||
const result = await fsManager.getAsBuffer(fileId);
|
||||
|
||||
@@ -64,6 +65,7 @@ describe('getAsBuffer()', () => {
|
||||
describe('getAsStream()', () => {
|
||||
it('should return a stream', async () => {
|
||||
fs.createReadStream = jest.fn().mockReturnValue(mockStream);
|
||||
fsp.access = jest.fn().mockImplementation(async () => {});
|
||||
|
||||
const stream = await fsManager.getAsStream(fileId);
|
||||
|
||||
@@ -123,6 +125,7 @@ describe('copyByFilePath()', () => {
|
||||
const targetPath = toFullFilePath(otherFileId);
|
||||
|
||||
fsp.cp = jest.fn().mockResolvedValue(undefined);
|
||||
fsp.writeFile = jest.fn().mockResolvedValue(undefined);
|
||||
|
||||
const result = await fsManager.copyByFilePath(
|
||||
workflowId,
|
||||
@@ -132,6 +135,11 @@ describe('copyByFilePath()', () => {
|
||||
);
|
||||
|
||||
expect(fsp.cp).toHaveBeenCalledWith(sourceFilePath, targetPath);
|
||||
expect(fsp.writeFile).toHaveBeenCalledWith(
|
||||
`${toFullFilePath(otherFileId)}.metadata`,
|
||||
JSON.stringify({ ...metadata, fileSize: mockBuffer.length }),
|
||||
{ encoding: 'utf-8' },
|
||||
);
|
||||
expect(result.fileSize).toBe(mockBuffer.length);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user