diff options
author | Pauli Järvinen <pauli.jarvinen@gmail.com> | 2021-09-11 17:42:15 +0300 |
---|---|---|
committer | Pauli Järvinen <pauli.jarvinen@gmail.com> | 2021-09-11 17:43:50 +0300 |
commit | a335592f14ad6af63c521bff92dc894c0efac870 (patch) | |
tree | ad849035225c5e479407df4f63af30504cd373d6 /lib/private/Files/Stream | |
parent | bc5350159eff3049b1c1808b6c1636629f30e297 (diff) | |
download | nextcloud-server-a335592f14ad6af63c521bff92dc894c0efac870.tar.gz nextcloud-server-a335592f14ad6af63c521bff92dc894c0efac870.zip |
Support seeking also from the end of file on S3 storage
The PR https://github.com/nextcloud/server/pull/20033 added support
for `fseek` for the S3 storage backend. However, the seek mode SEEK_END
was left out that time. This PR fills this gap.
Signed-off-by: Pauli Järvinen <pauli.jarvinen@gmail.com>
Diffstat (limited to 'lib/private/Files/Stream')
-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 c6d34e67cc9..af797c7720d 100644 --- a/lib/private/Files/Stream/SeekableHttpStream.php +++ b/lib/private/Files/Stream/SeekableHttpStream.php @@ -76,6 +76,8 @@ class SeekableHttpStream implements File { private $current; /** @var int */ private $offset = 0; + /** @var int */ + private $length = 0; private function reconnect(int $start) { $range = $start . '-'; @@ -101,12 +103,14 @@ class SeekableHttpStream implements File { $content = trim(explode(':', $contentRange)[1]); $range = trim(explode(' ', $content)[1]); $begin = intval(explode('-', $range)[0]); + $length = intval(explode('/', $range)[1]); if ($begin !== $start) { return false; } $this->offset = $begin; + $this->length = $length; return true; } @@ -140,7 +144,12 @@ class SeekableHttpStream implements File { } return $this->reconnect($this->offset + $offset); case SEEK_END: - return false; + if ($this->length === 0) { + return false; + } elseif ($this->length + $offset === $this->offset) { + return true; + } + return $this->reconnect($this->length + $offset); } return false; } |