Skip to content

Commit

Permalink
Merge pull request #45998 from nextcloud/publicdav-fs-setup
Browse files Browse the repository at this point in the history
perf: remove full filesystem setup for accessing public link share dav endpoints
  • Loading branch information
juliusknorr authored Jun 24, 2024
2 parents d361867 + 7a9efcf commit d086f3a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
15 changes: 8 additions & 7 deletions apps/dav/appinfo/v1/publicwebdav.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 7 additions & 11 deletions apps/dav/appinfo/v2/publicremote.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d086f3a

Please sign in to comment.