Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.list() ignores path parameter #33

Closed
victorstanciu opened this issue Dec 21, 2012 · 0 comments
Closed

.list() ignores path parameter #33

victorstanciu opened this issue Dec 21, 2012 · 0 comments

Comments

@victorstanciu
Copy link
Contributor

When trying to list the contents of a subdirectory, the .list method completely ignores the path parameter and only lists the CWD. If I cwd to a subdirectory first, and then call list without an additional path argument, it works:

var FTPClient = require('ftp');

var c = new FTPClient();

c.on('ready', function() {
    c.list(function (error, items) {
        if (error) { return console.log("ERROR: ", error); }

        console.log(
            "CWD contents:",
            items.map(function (item) { return item.name; })
        );

        c.list('subdirectory', function (error, items) {
            if (error) { return console.log("ERROR: ", error); }

            // This outputs the exact same items as before, despite having received a custom path parameter:
            console.log(
                "Subdirectory contents:",
                items.map(function (item) { return item.name; })
            );

            // If we CWD to the desired subdirectory first, IT WORKS:
            c.cwd('subdirectory', function (error, items) {
                c.list(function (error, items) {
                    if (error) { return console.log("ERROR: ", error); }

                    console.log(
                        "Subdirectory contents after CWD:",
                        items.map(function (item) { return item.name; })
                    );
                });
            });
        });
    });
});

c.connect({
    host: 'localhost',
    port: 21,
    user: 'ftp',
    password: 'ftp'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants