Skip to content

Commit

Permalink
Use path to determine the share mount
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliushaertl committed Oct 20, 2021
1 parent c21952b commit 8d8664e
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/private/Share20/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountManager;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\HintException;
use OCP\IConfig;
use OCP\IGroupManager;
Expand Down Expand Up @@ -292,13 +293,9 @@ protected function generalCreateChecks(IShare $share) {
$permissions = 0;

if (!$isFederatedShare && $share->getNode()->getOwner() && $share->getNode()->getOwner()->getUID() !== $share->getSharedBy()) {
$userMounts = array_filter($userFolder->getById($share->getNode()->getId()), function ($mount) use ($share) {
// We need to filter since there might be other mountpoints that contain the file
// e.g. if the user has access to the same external storage that the file is originating from
return $mount->getStorage()->instanceOfStorage(ISharedStorage::class) && $mount->getPath() === $share->getNode()->getPath();
});
$userMount = array_shift($userMounts);
if ($userMount === null) {
try {
$userMount = $this->rootFolder->get($share->getNode()->getPath());
} catch (NotFoundException $e) {
throw new GenericShareException('Could not get proper share mount for ' . $share->getNode()->getId() . '. Failing since else the next calls are called with null');
}
$mount = $userMount->getMountPoint();
Expand Down

0 comments on commit 8d8664e

Please sign in to comment.