From af6b57cd0df02db80eceeea39b0df5e0e8727e10 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 7 Sep 2020 20:53:56 +0200 Subject: 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 --- lib/private/Files/ObjectStore/ObjectStoreStorage.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/private/Files') 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) { -- cgit v1.2.3