diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2020-09-07 20:53:56 +0200 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2020-09-09 19:47:30 +0000 |
commit | af6b57cd0df02db80eceeea39b0df5e0e8727e10 (patch) | |
tree | fe694c3da4556c7ebf1bae1316b31f683041300d /lib/private/Files | |
parent | 7591a94902eb387c3dd1b0897da1fe8f2eca30e2 (diff) | |
download | nextcloud-server-af6b57cd0df02db80eceeea39b0df5e0e8727e10.tar.gz nextcloud-server-af6b57cd0df02db80eceeea39b0df5e0e8727e10.zip |
Fix reading empty files from objectstorage
Since we try to do range requests this will fail hard.
However since empty files are not that interesting to read anyways we
just read from an emptry memory stream.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Files')
-rw-r--r-- | lib/private/Files/ObjectStore/ObjectStoreStorage.php | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index bd5b2d47770..a752b27ca26 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -285,6 +285,11 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common { case 'rb': $stat = $this->stat($path); if (is_array($stat)) { + // Reading 0 sized files is a waste of time + if (isset($stat['size']) && $stat['size'] === 0) { + return fopen('php://memory', $mode); + } + try { return $this->objectStore->readObject($this->getURN($stat['fileid'])); } catch (NotFoundException $e) { |