Skip to content
This repository has been archived by the owner on Feb 5, 2022. It is now read-only.

Assign the SSH client to this object immediately #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lkwdwrd
Copy link

@lkwdwrd lkwdwrd commented Mar 20, 2016

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.

@@ -58,41 +58,40 @@ Client.prototype.sftp = function(callback) {
}

var self = this;
var ssh = new Connection();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var ssh = this._ssh = new Connection();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var ssh = this.__ssh = new Connection();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why __

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to use var ssh = this._ssh = new Connection(); like @popomore suggested.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants