Skip to content

Commit

Permalink
Merge pull request #29 from sergi/fix_nostat
Browse files Browse the repository at this point in the history
Fix for servers that don't support STAT command
  • Loading branch information
Sergi Mansilla committed Oct 24, 2012
2 parents e2759ab + a1cc114 commit cda55c4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
7 changes: 5 additions & 2 deletions lib/jsftp.js
Expand Up @@ -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/)
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion 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 <sergi.mansilla@gmail.com> (http://sergimansilla.com)",
Expand Down
14 changes: 3 additions & 11 deletions test/jsftp_test.js
Expand Up @@ -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));

Expand Down

0 comments on commit cda55c4

Please sign in to comment.