diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2022-12-01 15:42:07 -0100 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2022-12-01 15:42:15 -0100 |
commit | cc639a887734396158da0073b662711e8334b7ee (patch) | |
tree | d2b466ce27ffdc4ab3dba70950188f63692664f9 /lib/private/Files/Stream/SeekableHttpStream.php | |
parent | a51f0dbc6c93738dedd89885ffe816d97179ba1e (diff) | |
download | nextcloud-server-cc639a887734396158da0073b662711e8334b7ee.tar.gz nextcloud-server-cc639a887734396158da0073b662711e8334b7ee.zip |
compare cached filesize on download
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/private/Files/Stream/SeekableHttpStream.php')
-rw-r--r-- | lib/private/Files/Stream/SeekableHttpStream.php | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/private/Files/Stream/SeekableHttpStream.php b/lib/private/Files/Stream/SeekableHttpStream.php index df37fd29f42..51ccaeba998 100644 --- a/lib/private/Files/Stream/SeekableHttpStream.php +++ b/lib/private/Files/Stream/SeekableHttpStream.php @@ -75,8 +75,12 @@ class SeekableHttpStream implements File { /** @var ?resource|closed-resource */ private $current; + /** @var int $offset offset of the current chunk */ private int $offset = 0; + /** @var int $length length of the current chunk */ private int $length = 0; + /** @var int $totalSize size of the full stream */ + private int $totalSize = 0; private bool $needReconnect = false; private function reconnect(int $start): bool { @@ -128,6 +132,9 @@ class SeekableHttpStream implements File { $this->offset = $begin; $this->length = $length; + if ($start === 0) { + $this->totalSize = $length; + } return true; } @@ -211,7 +218,9 @@ class SeekableHttpStream implements File { public function stream_stat() { if ($this->getCurrent()) { - return fstat($this->getCurrent()); + $stat = fstat($this->getCurrent()); + $stat['size'] = $this->totalSize; + return $stat; } else { return false; } |