Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2022-07-05 11:51:13 +0300
committerMax <max@nextcloud.com>2022-07-06 11:51:53 +0300
commit940e1b5876516a6d95749fa4cf8df1e5c8018a29 (patch)
tree654b621e4d218c240fb98da48e7c83b6049b10fb
parentbfe8a1386b09412831c02a2208db954d4d845989 (diff)
Avoid duplicate queries and limit depth by default to 0
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-rw-r--r--lib/DAV/WorkspacePlugin.php51
1 files changed, 24 insertions, 27 deletions
diff --git a/lib/DAV/WorkspacePlugin.php b/lib/DAV/WorkspacePlugin.php
index b4019c6f1..2967833f6 100644
--- a/lib/DAV/WorkspacePlugin.php
+++ b/lib/DAV/WorkspacePlugin.php
@@ -84,6 +84,11 @@ class WorkspacePlugin extends ServerPlugin {
public function propFind(PropFind $propFind, INode $node) {
+ if (!in_array(self::WORKSPACE_PROPERTY, $propFind->getRequestedProperties())
+ && !in_array(self::WORKSPACE_FILE_PROPERTY, $propFind->getRequestedProperties())) {
+ return;
+ }
+
if (!$node instanceof Directory && !$node instanceof FilesHome) {
return;
}
@@ -95,37 +100,29 @@ class WorkspacePlugin extends ServerPlugin {
return;
}
+ $file = null;
+ $owner = $this->userId ?? $node->getFileInfo()->getStorage()->getOwner('');
+ /** @var Folder[] $nodes */
+ $nodes = $this->rootFolder->getUserFolder($owner)->getById($node->getId());
+ if (count($nodes) > 0) {
+ /** @var File $file */
+ try {
+ $file = $this->workspaceService->getFile($nodes[0]);
+ } catch (StorageNotAvailableException $e) {
+ // If a storage is not available we can for the propfind response assume that there is no rich workspace present
+ }
+ }
+
// Only return the property for the parent node and ignore it for further in depth nodes
- $propFind->handle(self::WORKSPACE_PROPERTY, function () use ($node) {
- $owner = $this->userId ?? $node->getFileInfo()->getStorage()->getOwner('');
- /** @var Folder[] $nodes */
- $nodes = $this->rootFolder->getUserFolder($owner)->getById($node->getId());
- if (count($nodes) > 0) {
- /** @var File $file */
- try {
- $file = $this->workspaceService->getFile($nodes[0]);
- if ($file instanceof File) {
- return $file->getContent();
- }
- } catch (StorageNotAvailableException $e) {
- // If a storage is not available we can for the propfind response assume that there is no rich workspace present
- }
+ $propFind->handle(self::WORKSPACE_PROPERTY, function () use ($file) {
+ if ($file instanceof File) {
+ return $file->getContent();
}
return '';
});
- $propFind->handle(self::WORKSPACE_FILE_PROPERTY, function () use ($node) {
- /** @var Folder[] $nodes */
- $nodes = $this->rootFolder->getUserFolder($this->userId)->getById($node->getId());
- if (count($nodes) > 0) {
- /** @var File $file */
- try {
- $file = $this->workspaceService->getFile($nodes[0]);
- if ($file instanceof File) {
- return $file->getFileInfo()->getId();
- }
- } catch (StorageNotAvailableException $e) {
- // If a storage is not available we can for the propfind response assume that there is no rich workspace present
- }
+ $propFind->handle(self::WORKSPACE_FILE_PROPERTY, function () use ($file) {
+ if ($file instanceof File) {
+ return $file->getFileInfo()->getId();
}
return '';
});