Soft fail in custom properties backend
This makes it possible for clients to still receive a file list (minus the broken files) instead of getting no list at all
This commit is contained in:
parent
093efa458c
commit
50194c31b4
|
@ -29,6 +29,7 @@ use Sabre\DAV\PropertyStorage\Backend\BackendInterface;
|
||||||
use Sabre\DAV\PropFind;
|
use Sabre\DAV\PropFind;
|
||||||
use Sabre\DAV\PropPatch;
|
use Sabre\DAV\PropPatch;
|
||||||
use Sabre\DAV\Tree;
|
use Sabre\DAV\Tree;
|
||||||
|
use Sabre\DAV\Exception\NotFound;
|
||||||
|
|
||||||
class CustomPropertiesBackend implements BackendInterface {
|
class CustomPropertiesBackend implements BackendInterface {
|
||||||
|
|
||||||
|
@ -94,8 +95,19 @@ class CustomPropertiesBackend implements BackendInterface {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function propFind($path, PropFind $propFind) {
|
public function propFind($path, PropFind $propFind) {
|
||||||
$node = $this->tree->getNodeForPath($path);
|
try {
|
||||||
if (!($node instanceof Node)) {
|
$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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,34 @@ class CustomPropertiesBackend extends \Test\TestCase {
|
||||||
$this->assertEquals(200, $result['customprop2']);
|
$this->assertEquals(200, $result['customprop2']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* Test setting/getting properties
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue