You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Guillaume Nodet (JIRA)" <ji...@apache.org> on 2013/07/17 21:33:49 UTC
[jira] [Resolved] (SSHD-229) SFTP download reopen files issue
[ https://issues.apache.org/jira/browse/SSHD-229?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Guillaume Nodet resolved SSHD-229.
----------------------------------
Resolution: Fixed
Fix Version/s: (was: 1.0.0)
Assignee: Guillaume Nodet
Fixed in a slightly different way to avoid accessing the underlying native file.
> SFTP download reopen files issue
> --------------------------------
>
> Key: SSHD-229
> URL: https://issues.apache.org/jira/browse/SSHD-229
> Project: MINA SSHD
> Issue Type: Improvement
> Affects Versions: 0.8.0, 0.9.0
> Reporter: Jr. John
> Assignee: Guillaume Nodet
> Fix For: 0.9.0
>
>
> org.apache.sshd.server.sftp.SftpSubsystem.java
> It's always reopen and close file when use sftp download files.
> public int read(byte[] data, long offset) throws IOException {
> if (input != null && offset != inputPos) {
> IoUtils.closeQuietly(input);
> input = null;
> }
> if (input == null) {
> input = file.createInputStream(offset);
> inputPos = offset;
> }
> int read = input.read(data);
> inputPos += read;
> return read;
> }
> I modify to bellow. it's open file one time when download. And faster 10x then old code.
> public int read(byte[] data, long offset) throws IOException {
>
> if (input == null) {
> input = new RandomAccessFile(((NativeSshFile)file).getPhysicalFile(), "r");
> }
>
> inputPos = offset;
> input.seek(inputPos);
> int read = input.read(data);
> inputPos += read;
> return read;
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira