]> source.dussan.org Git - nextcloud-server.git/commitdiff
Soft fail in CustomPropertiesBackend whenever storage not available
authorVincent Petry <pvince81@owncloud.com>
Mon, 23 Mar 2015 16:41:32 +0000 (17:41 +0100)
committerVincent Petry <pvince81@owncloud.com>
Mon, 23 Mar 2015 16:41:32 +0000 (17:41 +0100)
When a storage is not available, it will not fail the whole call any
more but still return a usable file list.

lib/private/connector/sabre/custompropertiesbackend.php
tests/lib/connector/sabre/custompropertiesbackend.php

index 6827cb9ae0dbb6fcd5172abfc94fd7d246214166..9bd6452674b1f52e5f1a327e8be7f3d5c69a6579 100644 (file)
@@ -30,6 +30,7 @@ use Sabre\DAV\PropFind;
 use Sabre\DAV\PropPatch;
 use Sabre\DAV\Tree;
 use Sabre\DAV\Exception\NotFound;
+use Sabre\DAV\Exception\ServiceUnavailable;
 
 class CustomPropertiesBackend implements BackendInterface {
 
@@ -100,6 +101,9 @@ class CustomPropertiesBackend implements BackendInterface {
                        if (!($node instanceof Node)) {
                                return;
                        }
+               } catch (ServiceUnavailable $e) {
+                       // might happen for unavailable mount points, skip
+                       return;
                } catch (NotFound $e) {
                        // in some rare (buggy) cases the node might not be found,
                        // we catch the exception to prevent breaking the whole list with a 404
index 8b6d1a90db1450321b8d5d51ec54eea1bf25b8d9..212bece9402c5e0e663f0951667cd5d4bbb6b408 100644 (file)
@@ -105,11 +105,16 @@ class CustomPropertiesBackend extends \Test\TestCase {
         * Test that propFind on a missing file soft fails
         */
        public function testPropFindMissingFileSoftFail() {
-               $this->tree->expects($this->any())
+               $this->tree->expects($this->at(0))
                        ->method('getNodeForPath')
                        ->with('/dummypath')
                        ->will($this->throwException(new \Sabre\DAV\Exception\NotFound()));
 
+               $this->tree->expects($this->at(1))
+                       ->method('getNodeForPath')
+                       ->with('/dummypath')
+                       ->will($this->throwException(new \Sabre\DAV\Exception\ServiceUnavailable()));
+
                $propFind = new \Sabre\DAV\PropFind(
                        '/dummypath',
                        array(
@@ -125,6 +130,11 @@ class CustomPropertiesBackend extends \Test\TestCase {
                        $propFind
                );
 
+               $this->plugin->propFind(
+                       '/dummypath',
+                       $propFind
+               );
+
                // no exception, soft fail
                $this->assertTrue(true);
        }