mirror of
https://github.com/nextcloud/server.git
synced 2026-05-26 19:32:28 -04:00
fix: check share target parent in userfolders mount
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
b6230eea7f
commit
fae8add994
2 changed files with 8 additions and 10 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Reference in a new issue