Compare commits

...

2 Commits

Author SHA1 Message Date
Tyler Stewart
577066850b fix: improve getting current directory 2017-03-30 12:26:04 -06:00
Tyler Stewart
0ec989cf1e docs: update login event for new root option 2017-03-29 10:20:22 -06:00
2 changed files with 7 additions and 4 deletions

View File

@@ -89,10 +89,13 @@ ftpServer.listen()
- __password__
- Password provided in the `PASS` command
- Only provided if `anonymous` is set to `false`
- __resolve ({fs, cwd, blacklist, whitelist})__
- __resolve ({fs, root, cwd, blacklist, whitelist})__
- __fs__ _[optional]_
- Optional file system class for connection to use
- See [File System](#file-system) for implementation details
- __root__ _[optional]_
- If `fs` not provided, will set the root directory for the connection
- The user cannot traverse lower than this directory
- __cwd__ _[optional]_
- If `fs` not provided, will set the starting directory for the connection
- __blacklist__ _[optional]_

View File

@@ -13,8 +13,8 @@ class FileSystem {
cwd = '/'
} = {}) {
this.connection = connection;
this.cwd = cwd;
this.root = root;
this.cwd = nodePath.resolve(cwd);
this.root = nodePath.resolve(root);
}
_resolvePath(path) {
@@ -60,7 +60,7 @@ class FileSystem {
if (!stat.isDirectory()) throw new errors.FileSystemError('Not a valid directory');
})
.then(() => {
this.cwd = path.replace(new RegExp(`^${this.root}`), '') || '/';
this.cwd = path.substring(this.root.length) || '/';
return this.currentDirectory();
});
}