diff options
author | Lukas Reschke <lukas@owncloud.com> | 2015-03-18 15:39:35 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2015-03-18 15:39:35 +0100 |
commit | 7310575f07d21cf8048799a0f8a36b2c384a455e (patch) | |
tree | e0e47994f9572b9bb370d99ac47e614dba2e86ed | |
parent | 917145e027adec8a7069e7b994a72d909a18dd2f (diff) | |
parent | 50194c31b42399cd27d178cccfc58a21f57f778c (diff) | |
download | nextcloud-server-7310575f07d21cf8048799a0f8a36b2c384a455e.tar.gz nextcloud-server-7310575f07d21cf8048799a0f8a36b2c384a455e.zip |
Merge pull request #14994 from owncloud/sabre-customprops-softfail
Soft fail in custom properties backend
-rw-r--r-- | lib/private/connector/sabre/custompropertiesbackend.php | 16 | ||||
-rw-r--r-- | tests/lib/connector/sabre/custompropertiesbackend.php | 28 |
2 files changed, 42 insertions, 2 deletions
diff --git a/lib/private/connector/sabre/custompropertiesbackend.php b/lib/private/connector/sabre/custompropertiesbackend.php index 76ac8b84ef9..6827cb9ae0d 100644 --- a/lib/private/connector/sabre/custompropertiesbackend.php +++ b/lib/private/connector/sabre/custompropertiesbackend.php @@ -29,6 +29,7 @@ use Sabre\DAV\PropertyStorage\Backend\BackendInterface; use Sabre\DAV\PropFind; use Sabre\DAV\PropPatch; use Sabre\DAV\Tree; +use Sabre\DAV\Exception\NotFound; class CustomPropertiesBackend implements BackendInterface { @@ -94,8 +95,19 @@ class CustomPropertiesBackend implements BackendInterface { * @return void */ public function propFind($path, PropFind $propFind) { - $node = $this->tree->getNodeForPath($path); - if (!($node instanceof Node)) { + try { + $node = $this->tree->getNodeForPath($path); + if (!($node instanceof Node)) { + 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 + // (soft fail) + \OC::$server->getLogger()->warning( + 'Could not get node for path: \"' . $path . '\" : ' . $e->getMessage(), + array('app' => 'files') + ); return; } diff --git a/tests/lib/connector/sabre/custompropertiesbackend.php b/tests/lib/connector/sabre/custompropertiesbackend.php index ee0c3c4e53d..8b6d1a90db1 100644 --- a/tests/lib/connector/sabre/custompropertiesbackend.php +++ b/tests/lib/connector/sabre/custompropertiesbackend.php @@ -102,6 +102,34 @@ class CustomPropertiesBackend extends \Test\TestCase { } /** + * Test that propFind on a missing file soft fails + */ + public function testPropFindMissingFileSoftFail() { + $this->tree->expects($this->any()) + ->method('getNodeForPath') + ->with('/dummypath') + ->will($this->throwException(new \Sabre\DAV\Exception\NotFound())); + + $propFind = new \Sabre\DAV\PropFind( + '/dummypath', + array( + 'customprop', + 'customprop2', + 'unsetprop', + ), + 0 + ); + + $this->plugin->propFind( + '/dummypath', + $propFind + ); + + // no exception, soft fail + $this->assertTrue(true); + } + + /** * Test setting/getting properties */ public function testSetGetPropertiesForFile() { |