ilang commented on PR #759:
URL: https://github.com/apache/commons-vfs/pull/759#issuecomment-4189370989
> Hello @ilang
>
> Please rebase on git master and review my comments.
>
> Isn't it possible that LIST would work when CDW could fail due to access
restrictions?
>
> TY!
Thanks, @garydgregory
Good point, had too look it up myself. and yes, CWD could fail due to access
restrictions while LIST on the parent would still work.
However, this is already handled correctly in the implementation.
If CWD fails for any reason (access denied, not a directory, or
non-existent), we fall back to the original parent LIST behavior:
in FTPFileObject :
private void setFTPFile(final boolean flush) throws IOException {
...
final FTPFile cwdResult = verifyDirectory();
if (cwdResult != null) {
newFileInfo = cwdResult;
} else {
newFileInfo =
parent.getChildFile(UriParser.decode(getName().getBaseName()), flush);
}
...
The only time we don't fall back is when this is a root directory, however
the root case is also covered: the factory already CWDs to the root directory
during connection setup.
if CWD fails, the connection itself fails with FileSystemException. So if a
user is connected, CWD "." on the root is guaranteed to work since they're
already in that directory.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]