mirror of
https://github.com/drakkan/sftpgo.git
synced 2024-11-25 17:10:28 +00:00
sftpfs: disable buffering for downloads if concurrent reads are disabled
This commit is contained in:
parent
1ee843757d
commit
d92861a8e8
1 changed files with 10 additions and 4 deletions
|
@ -262,10 +262,16 @@ func (fs *SFTPFs) Open(name string, offset int64) (File, *pipeat.PipeReaderAt, f
|
|||
return nil, nil, nil, err
|
||||
}
|
||||
go func() {
|
||||
br := bufio.NewReaderSize(f, int(fs.config.BufferSize)*1024*1024)
|
||||
// we don't use io.Copy since bufio.Reader implements io.ReadFrom and
|
||||
// so it calls the sftp.File ReadFrom method without buffering
|
||||
n, err := fs.copy(w, br)
|
||||
var n int64
|
||||
var err error
|
||||
if fs.config.DisableCouncurrentReads {
|
||||
n, err = fs.copy(w, f)
|
||||
} else {
|
||||
br := bufio.NewReaderSize(f, int(fs.config.BufferSize)*1024*1024)
|
||||
// we don't use io.Copy since bufio.Reader implements io.ReadFrom and
|
||||
// so it calls the sftp.File ReadFrom method without buffering
|
||||
n, err = fs.copy(w, br)
|
||||
}
|
||||
w.CloseWithError(err) //nolint:errcheck
|
||||
f.Close()
|
||||
fsLog(fs, logger.LevelDebug, "download completed, path: %#v size: %v, err: %v", name, n, err)
|
||||
|
|
Loading…
Reference in a new issue