fix(FTP Node): Fix "Maximum call stack size exceeded" error when dealing with too many files (#8657)
This commit is contained in:
committed by
GitHub
parent
66cbe54e1d
commit
506367453c
@@ -502,9 +502,7 @@ export class Ftp implements INodeType {
|
|||||||
|
|
||||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||||
const items = this.getInputData();
|
const items = this.getInputData();
|
||||||
// const returnData: IDataObject[] = [];
|
let returnItems: INodeExecutionData[] = [];
|
||||||
const returnItems: INodeExecutionData[] = [];
|
|
||||||
let responseData;
|
|
||||||
const operation = this.getNodeParameter('operation', 0);
|
const operation = this.getNodeParameter('operation', 0);
|
||||||
|
|
||||||
let credentials: ICredentialDataDecryptedObject | undefined = undefined;
|
let credentials: ICredentialDataDecryptedObject | undefined = undefined;
|
||||||
@@ -569,22 +567,19 @@ export class Ftp implements INodeType {
|
|||||||
|
|
||||||
const recursive = this.getNodeParameter('recursive', i) as boolean;
|
const recursive = this.getNodeParameter('recursive', i) as boolean;
|
||||||
|
|
||||||
|
let responseData: sftpClient.FileInfo[];
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
responseData = await callRecursiveList(path, sftp!, normalizeSFtpItem);
|
responseData = await callRecursiveList(path, sftp!, normalizeSFtpItem);
|
||||||
const executionData = this.helpers.constructExecutionMetaData(
|
|
||||||
this.helpers.returnJsonArray(responseData as unknown as IDataObject[]),
|
|
||||||
{ itemData: { item: i } },
|
|
||||||
);
|
|
||||||
returnItems.push.apply(returnItems, executionData);
|
|
||||||
} else {
|
} else {
|
||||||
responseData = await sftp!.list(path);
|
responseData = await sftp!.list(path);
|
||||||
responseData.forEach((item) => normalizeSFtpItem(item, path));
|
responseData.forEach((item) => normalizeSFtpItem(item, path));
|
||||||
const executionData = this.helpers.constructExecutionMetaData(
|
|
||||||
this.helpers.returnJsonArray(responseData as unknown as IDataObject[]),
|
|
||||||
{ itemData: { item: i } },
|
|
||||||
);
|
|
||||||
returnItems.push.apply(returnItems, executionData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const executionData = this.helpers.constructExecutionMetaData(
|
||||||
|
this.helpers.returnJsonArray(responseData as unknown as IDataObject[]),
|
||||||
|
{ itemData: { item: i } },
|
||||||
|
);
|
||||||
|
returnItems = returnItems.concat(executionData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operation === 'delete') {
|
if (operation === 'delete') {
|
||||||
@@ -592,15 +587,15 @@ export class Ftp implements INodeType {
|
|||||||
const options = this.getNodeParameter('options', i);
|
const options = this.getNodeParameter('options', i);
|
||||||
|
|
||||||
if (options.folder === true) {
|
if (options.folder === true) {
|
||||||
responseData = await sftp!.rmdir(path, !!options.recursive);
|
await sftp!.rmdir(path, !!options.recursive);
|
||||||
} else {
|
} else {
|
||||||
responseData = await sftp!.delete(path);
|
await sftp!.delete(path);
|
||||||
}
|
}
|
||||||
const executionData = this.helpers.constructExecutionMetaData(
|
const executionData = this.helpers.constructExecutionMetaData(
|
||||||
[{ json: { success: true } }],
|
[{ json: { success: true } }],
|
||||||
{ itemData: { item: i } },
|
{ itemData: { item: i } },
|
||||||
);
|
);
|
||||||
returnItems.push(...executionData);
|
returnItems = returnItems.concat(executionData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operation === 'rename') {
|
if (operation === 'rename') {
|
||||||
@@ -614,12 +609,12 @@ export class Ftp implements INodeType {
|
|||||||
await recursivelyCreateSftpDirs(sftp!, newPath);
|
await recursivelyCreateSftpDirs(sftp!, newPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
responseData = await sftp!.rename(oldPath, newPath);
|
await sftp!.rename(oldPath, newPath);
|
||||||
const executionData = this.helpers.constructExecutionMetaData(
|
const executionData = this.helpers.constructExecutionMetaData(
|
||||||
[{ json: { success: true } }],
|
[{ json: { success: true } }],
|
||||||
{ itemData: { item: i } },
|
{ itemData: { item: i } },
|
||||||
);
|
);
|
||||||
returnItems.push(...executionData);
|
returnItems = returnItems.concat(executionData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operation === 'download') {
|
if (operation === 'download') {
|
||||||
@@ -640,7 +635,7 @@ export class Ftp implements INodeType {
|
|||||||
this.helpers.returnJsonArray(items[i]),
|
this.helpers.returnJsonArray(items[i]),
|
||||||
{ itemData: { item: i } },
|
{ itemData: { item: i } },
|
||||||
);
|
);
|
||||||
returnItems.push(...executionData);
|
returnItems = returnItems.concat(executionData);
|
||||||
} finally {
|
} finally {
|
||||||
await binaryFile.cleanup();
|
await binaryFile.cleanup();
|
||||||
}
|
}
|
||||||
@@ -671,7 +666,7 @@ export class Ftp implements INodeType {
|
|||||||
this.helpers.returnJsonArray(items[i]),
|
this.helpers.returnJsonArray(items[i]),
|
||||||
{ itemData: { item: i } },
|
{ itemData: { item: i } },
|
||||||
);
|
);
|
||||||
returnItems.push(...executionData);
|
returnItems = returnItems.concat(executionData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -681,24 +676,21 @@ export class Ftp implements INodeType {
|
|||||||
|
|
||||||
const recursive = this.getNodeParameter('recursive', i) as boolean;
|
const recursive = this.getNodeParameter('recursive', i) as boolean;
|
||||||
|
|
||||||
|
let responseData;
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
responseData = await callRecursiveList(path, ftp!, normalizeFtpItem);
|
responseData = await callRecursiveList(path, ftp!, normalizeFtpItem);
|
||||||
const executionData = this.helpers.constructExecutionMetaData(
|
|
||||||
this.helpers.returnJsonArray(responseData as unknown as IDataObject[]),
|
|
||||||
{ itemData: { item: i } },
|
|
||||||
);
|
|
||||||
returnItems.push.apply(returnItems, executionData);
|
|
||||||
} else {
|
} else {
|
||||||
responseData = await ftp!.list(path);
|
responseData = await ftp!.list(path);
|
||||||
responseData.forEach((item) =>
|
responseData.forEach((item) =>
|
||||||
normalizeFtpItem(item as ftpClient.ListingElement, path),
|
normalizeFtpItem(item as ftpClient.ListingElement, path),
|
||||||
);
|
);
|
||||||
const executionData = this.helpers.constructExecutionMetaData(
|
|
||||||
this.helpers.returnJsonArray(responseData as unknown as IDataObject[]),
|
|
||||||
{ itemData: { item: i } },
|
|
||||||
);
|
|
||||||
returnItems.push.apply(returnItems, executionData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const executionData = this.helpers.constructExecutionMetaData(
|
||||||
|
this.helpers.returnJsonArray(responseData as unknown as IDataObject[]),
|
||||||
|
{ itemData: { item: i } },
|
||||||
|
);
|
||||||
|
returnItems = returnItems.concat(executionData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operation === 'delete') {
|
if (operation === 'delete') {
|
||||||
@@ -706,15 +698,16 @@ export class Ftp implements INodeType {
|
|||||||
const options = this.getNodeParameter('options', i);
|
const options = this.getNodeParameter('options', i);
|
||||||
|
|
||||||
if (options.folder === true) {
|
if (options.folder === true) {
|
||||||
responseData = await ftp!.rmdir(path, !!options.recursive);
|
await ftp!.rmdir(path, !!options.recursive);
|
||||||
} else {
|
} else {
|
||||||
responseData = await ftp!.delete(path);
|
await ftp!.delete(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
const executionData = this.helpers.constructExecutionMetaData(
|
const executionData = this.helpers.constructExecutionMetaData(
|
||||||
[{ json: { success: true } }],
|
[{ json: { success: true } }],
|
||||||
{ itemData: { item: i } },
|
{ itemData: { item: i } },
|
||||||
);
|
);
|
||||||
returnItems.push(...executionData);
|
returnItems = returnItems.concat(executionData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operation === 'download') {
|
if (operation === 'download') {
|
||||||
@@ -736,7 +729,7 @@ export class Ftp implements INodeType {
|
|||||||
this.helpers.returnJsonArray(items[i]),
|
this.helpers.returnJsonArray(items[i]),
|
||||||
{ itemData: { item: i } },
|
{ itemData: { item: i } },
|
||||||
);
|
);
|
||||||
returnItems.push(...executionData);
|
returnItems = returnItems.concat(executionData);
|
||||||
} finally {
|
} finally {
|
||||||
await binaryFile.cleanup();
|
await binaryFile.cleanup();
|
||||||
}
|
}
|
||||||
@@ -747,12 +740,12 @@ export class Ftp implements INodeType {
|
|||||||
|
|
||||||
const newPath = this.getNodeParameter('newPath', i) as string;
|
const newPath = this.getNodeParameter('newPath', i) as string;
|
||||||
|
|
||||||
responseData = await ftp!.rename(oldPath, newPath);
|
await ftp!.rename(oldPath, newPath);
|
||||||
const executionData = this.helpers.constructExecutionMetaData(
|
const executionData = this.helpers.constructExecutionMetaData(
|
||||||
[{ json: { success: true } }],
|
[{ json: { success: true } }],
|
||||||
{ itemData: { item: i } },
|
{ itemData: { item: i } },
|
||||||
);
|
);
|
||||||
returnItems.push(...executionData);
|
returnItems = returnItems.concat(executionData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operation === 'upload') {
|
if (operation === 'upload') {
|
||||||
@@ -801,7 +794,7 @@ export class Ftp implements INodeType {
|
|||||||
this.helpers.returnJsonArray(items[i]),
|
this.helpers.returnJsonArray(items[i]),
|
||||||
{ itemData: { item: i } },
|
{ itemData: { item: i } },
|
||||||
);
|
);
|
||||||
returnItems.push(...executionData);
|
returnItems = returnItems.concat(executionData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user