spmjs / node-scp2

[MAINTAINER WANTED] A pure javascript scp program based on ssh2.
384 stars 96 forks source link

Assign the SSH client to this object immediately #63

Open lkwdwrd opened 8 years ago

lkwdwrd commented 8 years ago

I've been doing some work that catches different connection errors and prompts the user for additional information. This works great except that the SSH client isn't assigned to the Connection object until after the connection. On error, the Connection object doesn't have a references to this.__ssh yet, meaning the close method does nothing to cancel out the current request.

This adjust the sftp method so that it assigns the ssh client to this.__ssh immediately and uses that as it's reference through the whole method. This has allowed me to properly clean up between connection attempts.