mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jr. John (JIRA)" <j...@apache.org>
Subject [jira] [Created] (SSHD-229) SFTP download reopen files issue
Date Wed, 08 May 2013 08:57:16 GMT
Jr. John created SSHD-229:
-----------------------------

             Summary: 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
             Fix For: 0.9.0, 1.0.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

Mime
View raw message