From 5c5707505b681584fcd2702b7e5a8a294a1d41f2 Mon Sep 17 00:00:00 2001 From: Sergi Mansilla Date: Wed, 24 Oct 2012 12:49:18 +0200 Subject: [PATCH 1/3] Fix for (mostly windows) servers with no STAT cmd --- lib/jsftp.js | 7 +++++-- test/jsftp_test.js | 22 +++++++--------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/lib/jsftp.js b/lib/jsftp.js index 5da122d..99d4410 100644 --- a/lib/jsftp.js +++ b/lib/jsftp.js @@ -628,6 +628,9 @@ var Ftp = module.exports = function(cfg) { if (err) return callback(err); + if (entries instanceof Buffer) + entries = entries.toString(); + callback(null, (entries.text || entries) .split(/\r\n|\n/) @@ -649,11 +652,11 @@ var Ftp = module.exports = function(cfg) { // 'STAT' command, which is set as default. We use 'LIST' instead, // and we set the variable `useList` to true, to avoid extra round // trips to the server to check. - if ((err && data && (data.code === 502 || data.code === 500)) || + if ((err && (err.code === 502 || err.code === 500)) || + (self.system && self.system.indexOf("hummingbird") > -1)) // Not sure if the "hummingbird" system check ^^^ is still // necessary. If they support any standards, the 500 error // should have us covered. Let's leave it for now. - (self.system && self.system.indexOf("hummingbird") > -1)) { self.useList = true; self.list(filePath, entriesToList); diff --git a/test/jsftp_test.js b/test/jsftp_test.js index 755de64..bf10d6a 100755 --- a/test/jsftp_test.js +++ b/test/jsftp_test.js @@ -19,10 +19,10 @@ var Path = require("path"); // FTP server. If you want to test against a remote server, simply change the // `host` and `port` properties as well. var FTPCredentials = { - host: "localhost", - user: "user", - port: 3334, - pass: "12345" + host: "10.0.2.15", + user: "sergi", + port: 21, + pass: "1234" }; var CWD = process.cwd() + "/test"; @@ -804,22 +804,14 @@ describe("jsftp test suite", function() { ftp.raw.pwd(function(err, res) { var parent, pathDir, path; - if (remoteCWD.charAt(0) !== "/") { - parent = /.*"(.*)".*/.exec(res.text)[1]; - pathDir = Path.resolve(parent + "/" + remoteCWD); - path = Path.resolve(pathDir + "/" + file1); - } - else { - pathDir = remoteCWD; - path = Path.resolve(remoteCWD + "/" + file1); - } + var path = remoteCWD + "/" + file1; ftp.put(path, new Buffer("test"), function(err, res) { assert.ok(!err); - ftp.raw.cwd(pathDir, function(err, res) { + ftp.raw.cwd(remoteCWD + "/", function(err, res) { ftp.ls(".", function(err, res) { - assert.ok(!err); + assert.ok(!err, err); assert.ok(Array.isArray(res)); From bbec8c017fbda92086017bf21e2ab10822f4291a Mon Sep 17 00:00:00 2001 From: Sergi Mansilla Date: Wed, 24 Oct 2012 12:54:29 +0200 Subject: [PATCH 2/3] Restore test credentials --- test/jsftp_test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/jsftp_test.js b/test/jsftp_test.js index bf10d6a..86ace58 100755 --- a/test/jsftp_test.js +++ b/test/jsftp_test.js @@ -19,10 +19,10 @@ var Path = require("path"); // FTP server. If you want to test against a remote server, simply change the // `host` and `port` properties as well. var FTPCredentials = { - host: "10.0.2.15", - user: "sergi", - port: 21, - pass: "1234" + host: "localhost", + user: "user", + port: 3334, + pass: "12345" }; var CWD = process.cwd() + "/test"; From a1cc1140d62ba9b137c176bf64414b6a6a4cd8eb Mon Sep 17 00:00:00 2001 From: Sergi Mansilla Date: Wed, 24 Oct 2012 12:55:12 +0200 Subject: [PATCH 3/3] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 90db881..1f4a30c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "jsftp", "id": "jsftp", - "version": "0.4.4", + "version": "0.4.5", "description": "A sane FTP client implementation for NodeJS", "keywords": [ "ftp", "protocol", "files", "server", "client", "async" ], "author": "Sergi Mansilla (http://sergimansilla.com)",