Skip to content

Commit abbab5c

Browse files
committed
fixup! Use user mount with matching shared storage only
1 parent 1d0c541 commit abbab5c

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

lib/private/Share20/Manager.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -300,17 +300,17 @@ protected function generalCreateChecks(IShare $share) {
300300
$isFederatedShare = $share->getNode()->getStorage()->instanceOfStorage('\OCA\Files_Sharing\External\Storage');
301301
$permissions = 0;
302302

303-
$userMounts = array_filter($userFolder->getById($share->getNode()->getId()), function ($mount) {
304-
// We need to filter since there might be other mountpoints that contain the file
305-
// e.g. if the user has access to the same external storage that the file is originating from
306-
return $mount->getStorage()->instanceOfStorage(ISharedStorage::class);
307-
});
308-
$userMount = array_shift($userMounts);
309-
if ($userMount === null) {
310-
throw new GenericShareException('Could not get proper share mount for ' . $share->getNode()->getId() . '. Failing since else the next calls are called with null');
311-
}
312-
$mount = $userMount->getMountPoint();
313303
if (!$isFederatedShare && $share->getNode()->getOwner() && $share->getNode()->getOwner()->getUID() !== $share->getSharedBy()) {
304+
$userMounts = array_filter($userFolder->getById($share->getNode()->getId()), function ($mount) {
305+
// We need to filter since there might be other mountpoints that contain the file
306+
// e.g. if the user has access to the same external storage that the file is originating from
307+
return $mount->getStorage()->instanceOfStorage(ISharedStorage::class);
308+
});
309+
$userMount = array_shift($userMounts);
310+
if ($userMount === null) {
311+
throw new GenericShareException('Could not get proper share mount for ' . $share->getNode()->getId() . '. Failing since else the next calls are called with null');
312+
}
313+
$mount = $userMount->getMountPoint();
314314
// When it's a reshare use the parent share permissions as maximum
315315
$userMountPointId = $mount->getStorageRootId();
316316
$userMountPoints = $userFolder->getById($userMountPointId);
@@ -339,7 +339,7 @@ protected function generalCreateChecks(IShare $share) {
339339
* while we 'most likely' do have that on the storage.
340340
*/
341341
$permissions = $share->getNode()->getPermissions();
342-
if (!($mount instanceof MoveableMount)) {
342+
if (!($share->getNode()->getMountPoint() instanceof MoveableMount)) {
343343
$permissions |= \OCP\Constants::PERMISSION_DELETE | \OCP\Constants::PERMISSION_UPDATE;
344344
}
345345
}

0 commit comments

Comments
 (0)