Closed Gooseus closed 9 years ago
So I forked this and may have fixed locally... my suspicion was that it had to do with the Client being instantiated once as a singleton and being reused across multiple scp calls. So I made this change:
https://github.com/Gooseus/node-scp2/compare/lepture:master...master
var Client = require('./client').Client;
function cp2remote(client, src, dest, callback) {
...
}
function cp2local(client, src, dest, callback) {
...
}
exports = module.exports = require('./client');
exports.scp = function(src, dest, callback) {
var client = new Client();
var parsed = client.parse(src);
client.on('error', callback);
if (parsed.host && parsed.path) {
cp2local(client, parsed, dest, callback);
} else {
cp2remote(client, src, dest, callback);
}
})
So basically I create a new Client each time and pass that in to the cp functions. Might be a performance hit, but for my use case (and most I think) file copying is expected to be expensive.
Let me know if want me to shoot you a pull request for this or if you have other thoughts or concerns on my approach.
This is a problem for subsequent scp(...) calls too. Gooseus' fork does the trick.
Is it fixed by this pr https://github.com/lepture/node-scp2/pull/19 ?
Yeah, it should at least. It resolved my issues performing multiple sequential scp actions.
Is there going to be an updated version available via npm any time soon? would be great :-)
@bschaepper 0.2.1 is released.
I am attempting to copy a directory remotely using SSH and public-key method. It will work once, and then I get this on the next attempt to upload.
The app then restarts and I'm able to make the request once again. It seems like one of the streams being used isn't being closed correctly or isn't be recreated when the scp call is made again?