lgoldstein commented on a change in pull request #207:
URL: https://github.com/apache/mina-sshd/pull/207#discussion_r739855590
##########
File path: docs/sftp.md
##########
@@ -532,7 +530,27 @@ if (directoryPath instanceof SftpPath) {
// Not an SFTP path -- get the directory listing in whatever other way is
appropriate.
}
```
-So even if an `SftpFileSystem` fulfills the general contract of a
`FileSystem`, a client still has to be aware that
+Alternatively, one can also use the fact that Apache MINA sshd caches the SFTP
file attributes on the `SftpPath` objects it
+returns from a `DirectoryStream`:
+
+```java
+public void processSftpDirectory(SftpPath directoryPath, BiConsumer<Path,
SftpClient.Attributes> process) throws IOException {
+ try (DirectoryStream<Path> dir = Files.newDirectoryStream(directoryPath)) {
+ for (Path path : dir) {
+ if (path instanceof SftpPath) {
+ SftpClient.Attributes attributes = ((SftpPath) path).getAttributes();
+ process.accept(path, attributes);
+ } else {
+ // A DirectoryStream on a directory given by an SftpPath always
returns SftpPath instances as elements.
+ throw new IllegalStateException();
Review comment:
Let's add a message to exception along the lines of "Iterated directory
entry=" + path + " is not an SftpPath as expected"
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]