Skip to content
This repository was archived by the owner on Feb 5, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,28 +227,25 @@ Client.prototype.write = function(options, callback) {
}
};

var step = _.throttle(function(total_transferred, chunk, total) {
self.emit(
"transfer",
undefined,
// percentage up to 99
// since it's incremented in the logger
Math.min(Math.floor(total_transferred / total * 100), 99),
100
),
100;
});
sftp.fastPut(
options.source,
path.basename(options.source),
{
step
},
function(err) {
step.cancel();
callback(err);
sftp.open(destination, 'w', attrs, function(err, handle) {
if (err) {
// destination is directory
destination = path.join(
destination, path.basename(options.source)
);
destination = unixy(destination);

// for emit write event
options.destination = destination;
sftp.open(destination, 'w', attrs, function(err, handle) {
_write(handle);
});
} else {
_write(handle);
}
);
});


});
};

Expand Down
2 changes: 1 addition & 1 deletion lib/scp.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ exports.Client = Client;
exports.scp = function(src, dest, client, callback) {
if (typeof client === 'function') {
callback = client;
client = new Client();
client = global_client;
}
client.on('error', callback);
var parsed = client.parse(src);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"async": "~0.9.0",
"glob": "~7.0.3",
"lodash": "~4.11.1",
"ssh2": "^0.6.0"
"ssh2": "^0.5.4"
},
"repository": {
"type": "git",
Expand Down