Browse Source

Update owner of subdir on move into/out of share

When moving a directory into or out of a received share, make sure to
also update the share owner column for shares that exist insie the
directory.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
pull/31728/head
Vincent Petry 4 years ago
committed by Louis (Rebase PR Action)
parent
commit
8ca910976d
  1. 19
      apps/files_sharing/lib/Updater.php

19
apps/files_sharing/lib/Updater.php

@ -29,6 +29,7 @@ namespace OCA\Files_Sharing;
use OC\Files\Mount\MountPoint;
use OCP\Constants;
use OCP\Share\IShare;
use OCP\Files\Folder;
class Updater {
@ -62,10 +63,20 @@ class Updater {
$shareManager = \OC::$server->getShareManager();
// FIXME: should CIRCLES be included here ??
$shares = $shareManager->getSharesBy($userFolder->getOwner()->getUID(), IShare::TYPE_USER, $src, false, -1);
$shares = array_merge($shares, $shareManager->getSharesBy($userFolder->getOwner()->getUID(), IShare::TYPE_GROUP, $src, false, -1));
$shares = array_merge($shares, $shareManager->getSharesBy($userFolder->getOwner()->getUID(), IShare::TYPE_ROOM, $src, false, -1));
if ($src instanceof Folder) {
// also check children
$subShares = $shareManager->getSharesInFolder($userFolder->getOwner()->getUID(), $src, false);
// flatten the result
foreach ($subShares as $subShare) {
$shares = array_merge($shares, array_values($subShare));
}
}
// If the path we move is not a share we don't care
if (empty($shares)) {
return;
@ -82,6 +93,14 @@ class Updater {
//Ownership is moved over
foreach ($shares as $share) {
if (
$share->getShareType() !== IShare::TYPE_USER &&
$share->getShareType() !== IShare::TYPE_GROUP &&
$share->getShareType() !== IShare::TYPE_ROOM
) {
continue;
}
/** @var IShare $share */
if (!($dstMount->getShare()->getPermissions() & Constants::PERMISSION_SHARE)) {
$shareManager->deleteShare($share);

Loading…
Cancel
Save