Skip to content
Merged

Fix/dav #2608

Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Avoid duplicate queries and limit depth by default to 0
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr authored and max-nextcloud committed Jul 6, 2022
commit 940e1b5876516a6d95749fa4cf8df1e5c8018a29
51 changes: 24 additions & 27 deletions lib/DAV/WorkspacePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ public function initialize(Server $server) {


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;
}
Expand All @@ -95,37 +100,29 @@ public function propFind(PropFind $propFind, INode $node) {
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 '';
});
Expand Down