diff options
author | Robin Appelman <robin@icewind.nl> | 2020-02-03 13:37:30 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2020-03-18 13:41:04 +0100 |
commit | 15a21ee19a7a0db41a7e20c15eb1943a6f5f37b8 (patch) | |
tree | 609417ef31e5ab03994b4dc6ccba3a222840f496 /apps/dav/lib/DAV/CustomPropertiesBackend.php | |
parent | 451c8761a710c62bc19b75ceba9de670b95aca9e (diff) | |
download | nextcloud-server-15a21ee19a7a0db41a7e20c15eb1943a6f5f37b8.tar.gz nextcloud-server-15a21ee19a7a0db41a7e20c15eb1943a6f5f37b8.zip |
remove the detour trough node and work with path directly
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/dav/lib/DAV/CustomPropertiesBackend.php')
-rw-r--r-- | apps/dav/lib/DAV/CustomPropertiesBackend.php | 42 |
1 files changed, 8 insertions, 34 deletions
diff --git a/apps/dav/lib/DAV/CustomPropertiesBackend.php b/apps/dav/lib/DAV/CustomPropertiesBackend.php index 5e0842200b4..8b0408a461b 100644 --- a/apps/dav/lib/DAV/CustomPropertiesBackend.php +++ b/apps/dav/lib/DAV/CustomPropertiesBackend.php @@ -102,25 +102,6 @@ class CustomPropertiesBackend implements BackendInterface { * @return void */ public function propFind($path, PropFind $propFind) { - try { - $node = $this->tree->getNodeForPath($path); - if (!($node instanceof INode)) { - 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 - // (soft fail) - \OC::$server->getLogger()->warning( - 'Could not get node for path: \"' . $path . '\" : ' . $e->getMessage(), - ['app' => 'files'] - ); - return; - } - $requestedProps = $propFind->get404Properties(); // these might appear @@ -153,7 +134,7 @@ class CustomPropertiesBackend implements BackendInterface { return; } - $props = $this->getProperties($node, $requestedProps); + $props = $this->getProperties($path, $requestedProps); foreach ($props as $propName => $propValue) { $propFind->set($propName, $propValue); } @@ -168,13 +149,8 @@ class CustomPropertiesBackend implements BackendInterface { * @return void */ public function propPatch($path, PropPatch $propPatch) { - $node = $this->tree->getNodeForPath($path); - if (!($node instanceof INode)) { - return; - } - - $propPatch->handleRemaining(function ($changedProps) use ($node) { - return $this->updateProperties($node, $changedProps); + $propPatch->handleRemaining(function ($changedProps) use ($path) { + return $this->updateProperties($path, $changedProps); }); } @@ -213,7 +189,7 @@ class CustomPropertiesBackend implements BackendInterface { /** * Returns a list of properties for this nodes.; * - * @param Node $node + * @param string $path * @param array $requestedProperties requested properties or empty array for "all" * @return array * @note The properties list is a list of propertynames the client @@ -221,8 +197,7 @@ class CustomPropertiesBackend implements BackendInterface { * http://www.example.org/namespace#author If the array is empty, all * properties should be returned */ - private function getProperties(INode $node, array $requestedProperties) { - $path = $node->getPath(); + private function getProperties(string $path, array $requestedProperties) { if (isset($this->cache[$path])) { return $this->cache[$path]; } @@ -260,13 +235,12 @@ class CustomPropertiesBackend implements BackendInterface { /** * Update properties * - * @param INode $node node for which to update properties + * @param string $path path for which to update properties * @param array $properties array of properties to update * * @return bool */ - private function updateProperties(INode $node, array $properties) { - $path = $node->getPath(); + private function updateProperties(string $path, array $properties) { $deleteStatement = 'DELETE FROM `*PREFIX*properties`' . ' WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = ?'; @@ -278,7 +252,7 @@ class CustomPropertiesBackend implements BackendInterface { ' WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = ?'; // TODO: use "insert or update" strategy ? - $existing = $this->getProperties($node, []); + $existing = $this->getProperties($path, []); $this->connection->beginTransaction(); foreach ($properties as $propertyName => $propertyValue) { // If it was null, we need to delete the property |