diff --git a/apps/files_external/lib/Lib/Storage/SFTPReadStream.php b/apps/files_external/lib/Lib/Storage/SFTPReadStream.php index c4749b154538e..1dbc09daac2c1 100644 --- a/apps/files_external/lib/Lib/Storage/SFTPReadStream.php +++ b/apps/files_external/lib/Lib/Storage/SFTPReadStream.php @@ -112,8 +112,6 @@ public function stream_open($path, $mode, $options, &$opened_path) { return false; } - $this->request_chunk(256 * 1024); - return true; } @@ -126,12 +124,10 @@ public function stream_tell() { } public function stream_read($count) { - if (!$this->eof && strlen($this->buffer) < $count) { + while (strlen($this->buffer) < $count && !$this->eof) { + $this->request_chunk(256 * 1024); $chunk = $this->read_chunk(); $this->buffer .= $chunk; - if (!$this->eof) { - $this->request_chunk(256 * 1024); - } } $data = substr($this->buffer, 0, $count);