diff --git a/apps/files_sharing/lib/ShareTargetValidator.php b/apps/files_sharing/lib/ShareTargetValidator.php index 0b359465ba9..9f2532c7879 100644 --- a/apps/files_sharing/lib/ShareTargetValidator.php +++ b/apps/files_sharing/lib/ShareTargetValidator.php @@ -9,12 +9,11 @@ declare(strict_types=1); namespace OCA\Files_Sharing; use OC\Files\Filesystem; -use OC\Files\SetupManager; use OC\Files\View; use OCP\Cache\CappedMemoryCache; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Config\ICachedMountInfo; -use OCP\Files\Mount\IMountManager; +use OCP\Files\IRootFolder; use OCP\Files\Mount\IMountPoint; use OCP\IUser; use OCP\Share\Events\VerifyMountPointEvent; @@ -30,8 +29,7 @@ class ShareTargetValidator { public function __construct( private readonly IManager $shareManager, private readonly IEventDispatcher $eventDispatcher, - private readonly SetupManager $setupManager, - private readonly IMountManager $mountManager, + private readonly IRootFolder $rootFolder, ) { $this->folderExistsCache = new CappedMemoryCache(); } @@ -67,8 +65,10 @@ class ShareTargetValidator { /** @psalm-suppress InternalMethod */ $absoluteParent = $recipientView->getAbsolutePath($parent); - $this->setupManager->setupForPath($absoluteParent); - $parentMount = $this->mountManager->find($absoluteParent); + + // the share target always has to be in the users home + $userFolder = $this->rootFolder->getUserFolder($user->getUID()); + $parentMount = $userFolder->getMountPoint(); $cached = $this->folderExistsCache->get($parent); if ($cached !== null) { diff --git a/apps/files_sharing/tests/ShareTargetValidatorTest.php b/apps/files_sharing/tests/ShareTargetValidatorTest.php index ee968c02e04..8bedfc306cc 100644 --- a/apps/files_sharing/tests/ShareTargetValidatorTest.php +++ b/apps/files_sharing/tests/ShareTargetValidatorTest.php @@ -9,12 +9,11 @@ declare(strict_types=1); namespace OCA\Files_Sharing\Tests; use OC\EventDispatcher\EventDispatcher; -use OC\Files\SetupManager; use OCA\Files_Sharing\ShareTargetValidator; use OCP\Constants; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Config\ICachedMountInfo; -use OCP\Files\Mount\IMountManager; +use OCP\Files\IRootFolder; use OCP\IUser; use OCP\Server; use OCP\Share\Events\VerifyMountPointEvent; @@ -57,8 +56,7 @@ class ShareTargetValidatorTest extends TestCase { $this->targetValidator = new ShareTargetValidator( Server::get(IManager::class), $this->eventDispatcher, - Server::get(SetupManager::class), - Server::get(IMountManager::class), + Server::get(IRootFolder::class), ); $this->user2 = $this->createMock(IUser::class); $this->user2->method('getUID')