summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2020-09-07 20:53:56 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2020-09-09 20:45:13 +0200
commitbb06b6cce46df881d84f34adfd5b1c3f315bd718 (patch)
tree1a14bf3cd41c4c13fe968e994277aa595ab8ecc6 /lib
parentcd563023dbceede717b22ce559f3efdf92b1da31 (diff)
downloadnextcloud-server-bb06b6cce46df881d84f34adfd5b1c3f315bd718.tar.gz
nextcloud-server-bb06b6cce46df881d84f34adfd5b1c3f315bd718.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')
-rw-r--r--lib/private/Files/ObjectStore/ObjectStoreStorage.php5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
index 950840301b0..e675064eb1f 100644
--- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php
+++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
@@ -296,6 +296,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) {