Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix execution of the custom `onConnect` handler #3

Merged
merged 6 commits into from

2 participants

@sergi

This fixes a bug introduced by the latest changes, in which a user custom onConnect callback passed in the options upon the Ftp client construction wouldn't be executed when the socket connects.

It also includes an upstream merge.

@ajaxorg/knuth @zefhemel

@zefhemel zefhemel merged commit c3dee03 into master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 13, 2012
  1. @sergi

    Changed code to continuation-style to avoid potential bugs

    sergi authored sergi committed
  2. @sergi

    No need for util dependency

    sergi authored
  3. @sergi

    Bump to 0.4.8

    sergi authored
Commits on Nov 14, 2012
  1. @sergi
  2. @sergi

    Merge upstream

    sergi authored
Commits on Nov 15, 2012
  1. @sergi

    Bump version to 0.4.9

    sergi authored
This page is out of date. Refresh to see the latest.
Showing with 22 additions and 4 deletions.
  1. +7 −3 lib/jsftp.js
  2. +1 −1  package.json
  3. +14 −0 test/jsftp_test.js
View
10 lib/jsftp.js
@@ -49,8 +49,9 @@ var Ftp = module.exports = function(cfg) {
// they will be sent to the server.
this.waitingForEnqueue = [];
- for (var option in cfg)
+ for (var option in cfg) {
if (!this[option]) this[option] = cfg[option];
+ }
this.port = this.port || FTP_PORT;
@@ -85,7 +86,7 @@ Ftp.queue = function() {
}
};
return stream;
-};
+};
// Codes from 100 to 200 are FTP marks
Ftp.isMark = function(code) {
@@ -113,7 +114,6 @@ Ftp.getPasvPort = function(text) {
var self = this;
// Stream of incoming data from the FTP server.
var input = function(next, stop) {
- _socket.on("connect", self.onConnect || function(){});
_socket.on("data", next);
_socket.on("end", stop);
_socket.on("error", stop);
@@ -249,6 +249,10 @@ Ftp.getPasvPort = function(text) {
this.socket.on("connect", function() {
self.connecting = false;
self.emitter.emit("connect", "connect");
+
+ if (self.onConnect)
+ self.onConnect();
+
self._createStreams(self.socket);
if (firstTask) {
View
2  package.json
@@ -1,7 +1,7 @@
{
"name": "jsftp",
"id": "jsftp",
- "version": "0.4.7",
+ "version": "0.4.9",
"description": "A sane FTP client implementation for NodeJS",
"keywords": [ "ftp", "protocol", "files", "server", "client", "async" ],
"author": "Sergi Mansilla <sergi.mansilla@gmail.com> (http://sergimansilla.com)",
View
14 test/jsftp_test.js
@@ -364,5 +364,19 @@ describe("jsftp test suite", function() {
});
});
});
+
+ it("test attach event handlers: connect", function(_next) {
+ var clientOnConnect = function() {
+ client.auth(FTPCredentials.user, FTPCredentials.pass, function(err) {
+ assert.ok(!err);
+ client.destroy();
+ _next();
+ });
+ };
+
+ FTPCredentials.onConnect = clientOnConnect;
+
+ var client = new Ftp(FTPCredentials);
+ });
});
Something went wrong with that request. Please try again.