summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/connector/sabre/file.php7
-rw-r--r--tests/lib/connector/sabre/file.php18
2 files changed, 23 insertions, 2 deletions
diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php
index 06e5c5a3a26..59818272a37 100644
--- a/lib/private/connector/sabre/file.php
+++ b/lib/private/connector/sabre/file.php
@@ -249,10 +249,13 @@ class File extends Node implements IFile {
* @throws ServiceUnavailable
*/
public function get() {
-
//throw exception if encryption is disabled but files are still encrypted
try {
- return $this->fileView->fopen(ltrim($this->path, '/'), 'rb');
+ $res = $this->fileView->fopen(ltrim($this->path, '/'), 'rb');
+ if ($res === false) {
+ throw new ServiceUnavailable("Could not open file");
+ }
+ return $res;
} catch (GenericEncryptionException $e) {
// returning 503 will allow retry of the operation at a later point in time
throw new ServiceUnavailable("Encryption not ready: " . $e->getMessage());
diff --git a/tests/lib/connector/sabre/file.php b/tests/lib/connector/sabre/file.php
index c9c7f55b58a..36a263633f6 100644
--- a/tests/lib/connector/sabre/file.php
+++ b/tests/lib/connector/sabre/file.php
@@ -779,4 +779,22 @@ class File extends \Test\TestCase {
closedir($dh);
return $files;
}
+
+ /**
+ * @expectedException \Sabre\DAV\Exception\ServiceUnavailable
+ */
+ public function testGetFopenFails() {
+ $view = $this->getMock('\OC\Files\View', ['fopen'], array());
+ $view->expects($this->atLeastOnce())
+ ->method('fopen')
+ ->will($this->returnValue(false));
+
+ $info = new \OC\Files\FileInfo('/test.txt', null, null, array(
+ 'permissions' => \OCP\Constants::PERMISSION_ALL
+ ), null);
+
+ $file = new \OC\Connector\Sabre\File($view, $info);
+
+ $file->get();
+ }
}