Created
September 14, 2011 17:09
-
-
Save sergi/1217130 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From ebb10691764938adec189da0e9f73e03a4291b2c Mon Sep 17 00:00:00 2001 | |
From: Sergi Mansilla <[email protected]> | |
Date: Wed, 14 Sep 2011 14:35:50 +0200 | |
Subject: [PATCH] Small optimizations | |
--- | |
jsftp.js | 22 +++++++++++++++------- | |
1 files changed, 15 insertions(+), 7 deletions(-) | |
diff --git a/jsftp.js b/jsftp.js | |
index 04d3f6e..d9b7912 100644 | |
--- a/jsftp.js | |
+++ b/jsftp.js | |
@@ -206,9 +206,17 @@ var Ftp = module.exports = function(cfg) { | |
*/ | |
tasks = S.zip(S.filter(function(x) { | |
// We ignore FTP marks for now. They don't convey useful | |
- // information. A more elegant solution should be found int he | |
+ // information. A more elegant solution should be found in the | |
// future. | |
- return !isMark(x.code); | |
+ var mark = isMark(x.code); | |
+ /* | |
+ if (mark) { | |
+ self.cmdListeners.forEach(function(listener) { | |
+ listener(null, x); | |
+ }); | |
+ } | |
+ */ | |
+ return !mark; | |
}, self.serverResponse(input)), S.append(S.list(null), cmds)); | |
tasks(self.parse.bind(self), function(err) { | |
@@ -314,13 +322,13 @@ var Ftp = module.exports = function(cfg) { | |
if (!action || !action[1]) | |
return; | |
+ var self = this; | |
var ftpResponse = action[0]; | |
var command = action[1]; | |
- var cleanCmd = this._sanitize(command[0]); | |
var callback = command[1]; | |
- this.cmdListeners.forEach(function(listener) { | |
- listener(cleanCmd, ftpResponse); | |
+ self.cmdListeners.forEach(function(listener) { | |
+ listener(self._sanitize(command[0]), ftpResponse); | |
}); | |
if (callback) { | |
@@ -359,8 +367,8 @@ var Ftp = module.exports = function(cfg) { | |
if (!cmd) | |
return; | |
- var _cmd = cmd.slice(0, 5).toUpperCase(); | |
- if (_cmd === "PASS ") | |
+ var _cmd = cmd.slice(0, 5); | |
+ if (_cmd === "pass ") | |
cmd = _cmd + Array(cmd.length - 5).join("*"); | |
return cmd; | |
-- | |
1.6.5+GitX |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment