mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
fix(Read Binary File Node): Do not crash the execution when the source file does not exist (#5100)
This issue was introduced in https://github.com/n8n-io/n8n/pull/5069
This commit is contained in:
committed by
GitHub
parent
c4df2049a8
commit
c97f3cad59
@@ -1,8 +1,6 @@
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
import { INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
||||
import type { IExecuteFunctions } from 'n8n-core';
|
||||
import type { INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
||||
import glob from 'fast-glob';
|
||||
import { createReadStream } from 'fs';
|
||||
import type { Readable } from 'stream';
|
||||
|
||||
export class ReadBinaryFiles implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -46,22 +44,17 @@ export class ReadBinaryFiles implements INodeType {
|
||||
const files = await glob(fileSelector);
|
||||
|
||||
const items: INodeExecutionData[] = [];
|
||||
let item: INodeExecutionData;
|
||||
let data: Readable;
|
||||
for (const filePath of files) {
|
||||
data = createReadStream(filePath);
|
||||
|
||||
item = {
|
||||
const stream = await this.helpers.createReadStream(filePath);
|
||||
items.push({
|
||||
binary: {
|
||||
[dataPropertyName]: await this.helpers.prepareBinaryData(data, filePath),
|
||||
[dataPropertyName]: await this.helpers.prepareBinaryData(stream, filePath),
|
||||
},
|
||||
json: {},
|
||||
pairedItem: {
|
||||
item: 0,
|
||||
},
|
||||
};
|
||||
|
||||
items.push(item);
|
||||
});
|
||||
}
|
||||
|
||||
return this.prepareOutputData(items);
|
||||
|
||||
Reference in New Issue
Block a user