You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2022/10/26 23:32:00 UTC
[jira] [Commented] (VFS-826) SFTP file get content issue for some servers
[ https://issues.apache.org/jira/browse/VFS-826?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17624789#comment-17624789 ]
Gary D. Gregory commented on VFS-826:
-------------------------------------
Hi [~Babin]
Feel free to propose a PR on GitHub.
> SFTP file get content issue for some servers
> --------------------------------------------
>
> Key: VFS-826
> URL: https://issues.apache.org/jira/browse/VFS-826
> Project: Commons VFS
> Issue Type: Bug
> Affects Versions: 2.9.0
> Reporter: Dmitry
> Priority: Major
>
> Some SFTP servers does not allow multiple channels open at same time,
> but SftpFileObject always open two if no hacks applied - at first just creates channel, then creates new channel to fetch type.
> Thus it is not possible to read the file in straightforward manner.
> Possible solution is to move file type check on top, so underlying code of getType will 'park' channel and then it will be reused.
> {code:java}
> protected InputStream doGetInputStream(int bufferSize) throws Exception {
> synchronized((SftpFileSystem)this.getAbstractFileSystem()) {
> ChannelSftp channel = ((SftpFileSystem)this.getAbstractFileSystem()).getChannel();
> InputStream inputStream;
> try {
> if (!this.getType().hasContent()) {
> throw new FileSystemException("vfs.provider/read-not-file.error", this.getName());
> }
> inputStream = channel.get(this.relPath);
> } catch (SftpException var7) {
> if (var7.id == 2) {
> throw new FileNotFoundException(this.getName());
> }
> throw new FileSystemException(var7);
> }
> return new SftpInputStream(channel, inputStream, bufferSize);
> }
> } {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)