Skip to content

Commit

Permalink
Merge branch 'master' of github.com:jyu213/ssh2-sftp-client
Browse files Browse the repository at this point in the history
  • Loading branch information
jyu213 committed Jun 7, 2016
2 parents 4deddea + 78d1177 commit 753bf8e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ SftpClient.prototype.get = function(path, useCompression) {

if (sftp) {
try {
resolve(sftp.createReadStream(path, useCompression));
let stream = sftp.createReadStream(path, useCompression);

stream.on('error', reject);

resolve(stream);
} catch(err) {
reject(err);
}
Expand Down Expand Up @@ -105,9 +109,8 @@ SftpClient.prototype.put = function(input, remotePath, useCompression) {
let stream = sftp.createWriteStream(remotePath, useCompression);
let data;

stream.on('close', () => {
resolve();
});
stream.on('error', reject);
stream.on('close', resolve);

if (input instanceof Buffer) {
data = stream.end(input);
Expand Down

0 comments on commit 753bf8e

Please sign in to comment.