hierynomus / sshj

ssh, scp and sftp for java
Apache License 2.0
2.49k stars 602 forks source link

Support premature termination of listing #928

Closed EndzeitBegins closed 5 months ago

EndzeitBegins commented 7 months ago

Adds the notion of a RemoteResourceSelector which is a more powerful alternative of the existing RemoteResourceFilter allowing to terminate a listing prematurely.

An improvement to Apache NiFi aims to support listing a configured maximum of remote file resources. As of now, this can be achieved by providing a RemoteResourceFilter that returns false for all RemoteResourceInfo after the configured threshold has been reached. However, sshj will list all files under the hood nonetheless, which has huge affect on listing performance, especially for directories a with large amount of files.

The PR also resolved a TODO to remove the GOTO that resided in the code touched.

Please let me know if this is a good trajectory for addressing the underlying problem stated or whether it should be addressed differently or any other changes should be incorporated.