summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2018-10-22 15:54:37 +0200
committerRobin Appelman <robin@icewind.nl>2018-10-23 17:46:09 +0200
commit13317da19a1b8b5d879ca3881fe1fdab2a56548b (patch)
treef478b60a5bebaa26c21b39d840744ebb3a70f4bf /apps
parent5de5db0280a1a69d2899a9fb6027e50681f6d724 (diff)
downloadnextcloud-server-13317da19a1b8b5d879ca3881fe1fdab2a56548b.tar.gz
nextcloud-server-13317da19a1b8b5d879ca3881fe1fdab2a56548b.zip
lazy open first source stream in assemblystream
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/Upload/AssemblyStream.php11
1 files changed, 6 insertions, 5 deletions
diff --git a/apps/dav/lib/Upload/AssemblyStream.php b/apps/dav/lib/Upload/AssemblyStream.php
index 3ba24bf60fd..1a73669698b 100644
--- a/apps/dav/lib/Upload/AssemblyStream.php
+++ b/apps/dav/lib/Upload/AssemblyStream.php
@@ -73,9 +73,6 @@ class AssemblyStream implements \Icewind\Streams\File {
return strnatcmp($a->getName(), $b->getName());
});
$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) {
return $size + $file->getSize();
}, 0);
@@ -104,7 +101,11 @@ class AssemblyStream implements \Icewind\Streams\File {
*/
public function stream_read($count) {
if (is_null($this->currentStream)) {
- return '';
+ if ($this->currentNode < count($this->nodes)) {
+ $this->currentStream = $this->getStream($this->nodes[$this->currentNode]);
+ } else {
+ return '';
+ }
}
do {
@@ -182,7 +183,7 @@ class AssemblyStream implements \Icewind\Streams\File {
* @return bool
*/
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);
}
/**