From 7a9efcf4ccf24cb015a48d58c0b0ae9149f540ac Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 20 Jun 2024 10:37:25 +0200 Subject: [PATCH] perf: remove full filesystem setup for accessing public link share dav endpoints Signed-off-by: Robin Appelman --- apps/dav/appinfo/v1/publicwebdav.php | 15 ++++++++------- apps/dav/appinfo/v2/publicremote.php | 18 +++++++----------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/apps/dav/appinfo/v1/publicwebdav.php b/apps/dav/appinfo/v1/publicwebdav.php index dd4b592bd140e..5ef383e1dd5d7 100644 --- a/apps/dav/appinfo/v1/publicwebdav.php +++ b/apps/dav/appinfo/v1/publicwebdav.php @@ -72,19 +72,20 @@ }); \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog); - OC_Util::tearDownFS(); - OC_Util::setupFS($owner); - $ownerView = new \OC\Files\View('/'. $owner . '/files'); - $path = $ownerView->getPath($fileId); - $fileInfo = $ownerView->getFileInfo($path); - $linkCheckPlugin->setFileInfo($fileInfo); + $rootFolder = \OCP\Server::get(\OCP\Files\IRootFolder::class); + $userFolder = $rootFolder->getUserFolder($owner); + $node = $userFolder->getFirstNodeById($fileId); + if (!$node) { + throw new \Sabre\DAV\Exception\NotFound(); + } + $linkCheckPlugin->setFileInfo($node); // If not readable (files_drop) enable the filesdrop plugin if (!$isReadable) { $filesDropPlugin->enable(); } - $view = new \OC\Files\View($ownerView->getAbsolutePath($path)); + $view = new \OC\Files\View($node->getPath()); $filesDropPlugin->setView($view); return $view; diff --git a/apps/dav/appinfo/v2/publicremote.php b/apps/dav/appinfo/v2/publicremote.php index 5f20c94c574f4..bdc4169dd4ebe 100644 --- a/apps/dav/appinfo/v2/publicremote.php +++ b/apps/dav/appinfo/v2/publicremote.php @@ -101,24 +101,20 @@ /** @psalm-suppress InternalMethod */ Filesystem::logWarningWhenAddingStorageWrapper($previousLog); - OC_Util::tearDownFS(); - OC_Util::setupFS($owner); - $ownerView = new View('/'. $owner . '/files'); - $path = $ownerView->getPath($fileId); - $fileInfo = $ownerView->getFileInfo($path); - - if ($fileInfo === false) { + $rootFolder = \OCP\Server::get(\OCP\Files\IRootFolder::class); + $userFolder = $rootFolder->getUserFolder($owner); + $node = $userFolder->getFirstNodeById($fileId); + if (!$node) { throw new NotFound(); } + $linkCheckPlugin->setFileInfo($node); - $linkCheckPlugin->setFileInfo($fileInfo); - - // If not readble (files_drop) enable the filesdrop plugin + // If not readable (files_drop) enable the filesdrop plugin if (!$isReadable) { $filesDropPlugin->enable(); } - $view = new View($ownerView->getAbsolutePath($path)); + $view = new View($node->getPath()); $filesDropPlugin->setView($view); return $view;