From 49c1bf208ffbb63b64680189c4d1c53ed8292742 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Thu, 29 Jan 2026 15:45:00 +0100 Subject: [PATCH] perf: Get readme from folder Directly get all markdown files from parent directory in one SQL query and then filter on it by name. Signed-off-by: Carl Schwan --- lib/DAV/WorkspacePlugin.php | 3 +-- lib/Service/WorkspaceService.php | 12 ++++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/DAV/WorkspacePlugin.php b/lib/DAV/WorkspacePlugin.php index fa4bc5568a7..a3005852ea8 100644 --- a/lib/DAV/WorkspacePlugin.php +++ b/lib/DAV/WorkspacePlugin.php @@ -10,7 +10,6 @@ use Exception; use OC\Files\Node\File; -use OCA\DAV\Connector\Sabre\Directory; use OCA\DAV\Files\FilesHome; use OCA\Text\Service\ConfigService; use OCA\Text\Service\WorkspaceService; @@ -64,7 +63,7 @@ public function propFind(PropFind $propFind, INode $node) { return; } - if (!$node instanceof Directory && !$node instanceof FilesHome) { + if (!$node instanceof FilesHome) { return; } diff --git a/lib/Service/WorkspaceService.php b/lib/Service/WorkspaceService.php index 1f8191f7d56..9342fb8f179 100644 --- a/lib/Service/WorkspaceService.php +++ b/lib/Service/WorkspaceService.php @@ -10,9 +10,6 @@ use OCP\Files\File; use OCP\Files\Folder; -use OCP\Files\NotFoundException; -use OCP\Files\NotPermittedException; -use OCP\Files\StorageInvalidException; use OCP\IL10N; class WorkspaceService { @@ -28,14 +25,13 @@ public function __construct( } public function getFile(Folder $folder): ?File { - foreach ($this->getSupportedFilenames() as $filename) { - try { - $file = $folder->get($filename); + $content = $folder->getStorage()->getCache()->getFolderContents($folder->getInternalPath() . '/', 'text/markdown'); + foreach ($content as $file) { + if (in_array($file->getName(), $this->getSupportedFilenames(), true)) { + $file = $folder->get($file->getPath()); if ($file instanceof File) { return $file; } - } catch (NotFoundException|NotPermittedException|StorageInvalidException) { - continue; } } return null;