mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
⚡ Add delete folder operation to FTP Node (#1704)
* ⚡ Add delete folder operation to FTP Node * ⚡ Minor improvement Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
parent
b6d45e30ef
commit
901551ae99
|
@ -102,7 +102,7 @@ export class Ftp implements INodeType {
|
|||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
description: 'Delete a file.',
|
||||
description: 'Delete a file/folder.',
|
||||
},
|
||||
{
|
||||
name: 'Download',
|
||||
|
@ -148,6 +148,46 @@ export class Ftp implements INodeType {
|
|||
required: true,
|
||||
},
|
||||
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Option',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'delete',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Folder',
|
||||
name: 'folder',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'When set to true, folders can be deleted.',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Recursive',
|
||||
displayOptions: {
|
||||
show: {
|
||||
folder: [
|
||||
true,
|
||||
],
|
||||
},
|
||||
},
|
||||
name: 'recursive',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'If true, remove all files and directories in target directory.',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
// ----------------------------------
|
||||
// download
|
||||
// ----------------------------------
|
||||
|
@ -401,8 +441,13 @@ export class Ftp implements INodeType {
|
|||
|
||||
if (operation === 'delete') {
|
||||
const path = this.getNodeParameter('path', i) as string;
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
|
||||
if (options.folder === true) {
|
||||
responseData = await sftp!.rmdir(path, !!options.recursive);
|
||||
} else {
|
||||
responseData = await sftp!.delete(path);
|
||||
}
|
||||
|
||||
returnItems.push({ json: { success: true } });
|
||||
}
|
||||
|
@ -488,8 +533,13 @@ export class Ftp implements INodeType {
|
|||
|
||||
if (operation === 'delete') {
|
||||
const path = this.getNodeParameter('path', i) as string;
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
|
||||
if (options.folder === true) {
|
||||
responseData = await ftp!.rmdir(path, !!options.recursive);
|
||||
} else {
|
||||
responseData = await ftp!.delete(path);
|
||||
}
|
||||
|
||||
returnItems.push({ json: { success: true } });
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue