Merge pull request #11997 from nextcloud/assemblly-stream-lazy-13
lazy open first source stream in assemblystream
This commit is contained in:
commit
c3919b844b
|
@ -73,9 +73,6 @@ class AssemblyStream implements \Icewind\Streams\File {
|
||||||
return strnatcmp($a->getName(), $b->getName());
|
return strnatcmp($a->getName(), $b->getName());
|
||||||
});
|
});
|
||||||
$this->nodes = array_values($nodes);
|
$this->nodes = array_values($nodes);
|
||||||
if (count($this->nodes) > 0) {
|
|
||||||
$this->currentStream = $this->getStream($this->nodes[0]);
|
|
||||||
}
|
|
||||||
$this->size = array_reduce($this->nodes, function ($size, IFile $file) {
|
$this->size = array_reduce($this->nodes, function ($size, IFile $file) {
|
||||||
return $size + $file->getSize();
|
return $size + $file->getSize();
|
||||||
}, 0);
|
}, 0);
|
||||||
|
@ -104,7 +101,11 @@ class AssemblyStream implements \Icewind\Streams\File {
|
||||||
*/
|
*/
|
||||||
public function stream_read($count) {
|
public function stream_read($count) {
|
||||||
if (is_null($this->currentStream)) {
|
if (is_null($this->currentStream)) {
|
||||||
return '';
|
if ($this->currentNode < count($this->nodes)) {
|
||||||
|
$this->currentStream = $this->getStream($this->nodes[$this->currentNode]);
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
@ -182,7 +183,7 @@ class AssemblyStream implements \Icewind\Streams\File {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function stream_eof() {
|
public function stream_eof() {
|
||||||
return $this->pos >= $this->size || $this->currentStream === null;
|
return $this->pos >= $this->size || ($this->currentNode >= count($this->nodes) && $this->currentNode === null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue