Socket
Socket
Sign inDemoInstall

ssh2-sftp-client

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ssh2-sftp-client - npm Package Compare versions

Comparing version 8.0.0 to 8.1.0

10

package.json
{
"name": "ssh2-sftp-client",
"version": "8.0.0",
"version": "8.1.0",
"description": "ssh2 sftp client for node",

@@ -10,3 +10,7 @@ "main": "src/index.js",

},
"keywords": ["sftp", "nodejs", "promises"],
"keywords": [
"sftp",
"nodejs",
"promises"
],
"scripts": {

@@ -51,4 +55,4 @@ "test": "mocha",

"promise-retry": "^2.0.1",
"ssh2": "^1.9.0"
"ssh2": "^1.10.0"
}
}

@@ -431,2 +431,3 @@ /**

group: item.attrs.gid,
longname: item.longname,
};

@@ -794,41 +795,59 @@ });

*/
async append(input, remotePath, options = {}) {
const fileType = await this.exists(remotePath);
if (fileType && fileType === 'd') {
throw fmtError(
`Bad path: ${remotePath}: cannot append to a directory`,
'append',
errorCode.badPath
);
}
let listeners;
return await new Promise((resolve, reject) => {
listeners = addTempListeners(this, 'append', reject);
if (haveConnection(this, 'append', reject)) {
if (typeof input === 'string') {
reject(fmtError('Cannot append one file to another', 'append'));
const _append = (input, remotePath, options) => {
return new Promise((resolve, reject) => {
this.debugMsg(`append -> remote: ${remotePath} `, options);
options.flags = 'a';
let stream = this.sftp.createWriteStream(remotePath, options);
stream.on('error', (err) => {
this.debugMsg(
`append: Error ${err.message} appending to ${remotePath}`
);
reject(fmtError(`${err.message} ${remotePath}`, 'append', err.code));
});
stream.on('close', () => {
this.debugMsg(`append: data appended to ${remotePath}`);
resolve(`Appended data to ${remotePath}`);
});
if (input instanceof Buffer) {
this.debugMsg('append: writing data buffer to remote file');
stream.write(input);
stream.end();
} else {
this.debugMsg(`append -> remote: ${remotePath} `, options);
options.flags = 'a';
let stream = this.sftp.createWriteStream(remotePath, options);
stream.on('error', (err_1) => {
reject(
fmtError(`${err_1.message} ${remotePath}`, 'append', err_1.code)
);
});
stream.on('finish', () => {
resolve(`Appended data to ${remotePath}`);
});
if (input instanceof Buffer) {
stream.write(input);
stream.end();
} else {
input.pipe(stream);
}
this.debugMsg('append: writing stream to remote file');
input.pipe(stream);
}
});
};
let listeners;
try {
listeners = addTempListeners(this, 'append');
if (typeof input === 'string') {
this.debugMsg('append: attempt to append two files - throw');
throw fmtError(
'Cannot append one file to another',
'append',
errorCode.badPath
);
}
}).finally(() => {
if (haveConnection(this, 'append')) {
const fileType = await this.exists(remotePath);
if (fileType && fileType === 'd') {
this.debugMsg(`append: Error ${remotePath} not a file`);
throw fmtError(
`Bad path: ${remotePath}: cannot append to a directory`,
'append',
errorCode.badPath
);
}
await _append(input, remotePath, options);
}
} catch (e) {
throw e.custom ? e : fmtError(e.message, 'append', e.code);
} finally {
removeTempListeners(this, listeners, 'append');
this._resetEventFlags();
});
}
}

@@ -956,2 +975,5 @@

this.debugMsg('rmdir contents (dirs): ', dirs);
for (let d of dirs) {
await _dormdir(`${p}${this.remotePathSep}${d.name}`, true);
}
let promiseList = [];

@@ -961,7 +983,2 @@ for (let f of files) {

}
for (let d of dirs) {
promiseList.push(
_dormdir(`${p}${this.remotePathSep}${d.name}`, true)
);
}
await Promise.all(promiseList);

@@ -1153,4 +1170,3 @@ }

* @param {String} dstDir - remote destination directory
* @param {RegExp} filter - (Optional) a regular expression used to select
* files and directories to upload
* @param {function(String,Boolean):Boolean} filter - (Optional) The first argument is the full path of the item to be uploaded and the second argument is a boolean, which will be true if the target path is for a directory. If the function returns true, the item will be uploaded
* @returns {Promise<String>}

@@ -1232,4 +1248,3 @@ */

* @param {String} dstDir - local destination directory
* @param {RegExp} filter - (Optional) a regular expression used to select
* files and directories to upload
* @param {function(String,Boolean):Boolean} filter - (Optional) The first argument is the full path of the item to be downloaded and the second argument is a boolean, which will be true if the target path is for a directory. If the function returns true, the item will be downloaded
* @returns {Promise<String>}

@@ -1236,0 +1251,0 @@ */

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc