mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-13 05:47:31 -08:00
⚡ SFTP: make dir creation more robust (#1166)
This commit is contained in:
parent
032e2dfae5
commit
c57250c71f
|
@ -348,13 +348,11 @@ export class Ftp implements INodeType {
|
||||||
const remotePath = this.getNodeParameter('path', i) as string;
|
const remotePath = this.getNodeParameter('path', i) as string;
|
||||||
|
|
||||||
// Check if dir path exists
|
// Check if dir path exists
|
||||||
const dirExists = await sftp!.exists(dirname(remotePath));
|
const dirPath = dirname(remotePath);
|
||||||
|
const dirExists = await sftp!.exists(dirPath);
|
||||||
|
|
||||||
// If dir does not exist, create all recursively in path
|
// If dir does not exist, create all recursively in path
|
||||||
if (!dirExists) {
|
if (!dirExists) {
|
||||||
// Separate filename from dir path
|
|
||||||
const fileName = basename(remotePath);
|
|
||||||
const dirPath = remotePath.replace(fileName, '');
|
|
||||||
// Create directory
|
// Create directory
|
||||||
await sftp!.mkdir(dirPath, true);
|
await sftp!.mkdir(dirPath, true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue