From 9f02d8ce7d5ee0ed7daab602756f0958dcdea11f Mon Sep 17 00:00:00 2001 From: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com> Date: Fri, 13 Feb 2026 17:22:18 +0100 Subject: [PATCH] fix: remove user part only at the beginning of path Signed-off-by: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com> --- lib/Db/ShareWrapperRequest.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Db/ShareWrapperRequest.php b/lib/Db/ShareWrapperRequest.php index 4e033fe72..dbfff3ba7 100644 --- a/lib/Db/ShareWrapperRequest.php +++ b/lib/Db/ShareWrapperRequest.php @@ -24,6 +24,7 @@ use OCP\Share\Exceptions\IllegalIDChangeException; use OCP\Share\IAttributes; use OCP\Share\IShare; +use function strlen; /** * Class ShareWrapperRequest @@ -383,10 +384,13 @@ public function getSharedWithByPath( $qb->limitNull('parent', false); $childAlias = $qb->leftJoinShareChild(CoreQueryBuilder::SHARE); + $userId = $federatedUser->getUserId(); + if (str_starts_with($path, '/' . $userId . '/files')) { + $path = substr($path, strlen('/' . $userId . '/files')); + } + $path = rtrim($path, '/'); + if ($forChildren) { - $userId = $federatedUser->getUserId(); - $path = str_replace('/' . $userId . '/files', '', $path); - $path = rtrim($path, '/'); $childPathTemplate = $this->getQueryBuilder()->getConnection()->escapeLikeParameter($path) . '/_%'; $qb->limitToFileTargetLike($childPathTemplate, $childAlias);