diff options
author | Julius Härtl <jus@bitgrid.net> | 2021-09-14 13:52:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-14 13:52:28 +0200 |
commit | 8e7f63b2749c3fe6058cebcab5cfa6ff0424d02f (patch) | |
tree | fa996d0b7847b9c574d621e202c501ab280aaaa9 /lib | |
parent | 1e6e0cf7b67dadb1e589121ced65aad3bbd88433 (diff) | |
parent | a335592f14ad6af63c521bff92dc894c0efac870 (diff) | |
download | nextcloud-server-8e7f63b2749c3fe6058cebcab5cfa6ff0424d02f.tar.gz nextcloud-server-8e7f63b2749c3fe6058cebcab5cfa6ff0424d02f.zip |
Merge pull request #28802 from paulijar/enh/s3_seek_from_end
Support seeking also from the end of file on S3 storage
Diffstat (limited to 'lib')
-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; } |