Skip to content

Commit

Permalink
fix: always handle workspace properties
Browse files Browse the repository at this point in the history
Signed-off-by: Max <max@nextcloud.com>
  • Loading branch information
max-nextcloud committed Jun 22, 2022
1 parent 7db992a commit c24534a
Showing 1 changed file with 29 additions and 31 deletions.
60 changes: 29 additions & 31 deletions lib/DAV/WorkspacePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,40 +96,38 @@ public function propFind(PropFind $propFind, INode $node) {
}

// Only return the property for the parent node and ignore it for further in depth nodes
if ($propFind->getDepth() === $this->server->getHTTPDepth(1)) {
$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 ($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
}
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
}
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
}
return '';
});
}
}
return '';
});
}
}

0 comments on commit c24534a

Please sign in to comment.