diff options
author | Vincent Petry <vincent@nextcloud.com> | 2022-03-28 09:28:37 +0200 |
---|---|---|
committer | Louis (Rebase PR Action) <artonge@users.noreply.github.com> | 2022-07-26 12:17:46 +0000 |
commit | 8ca910976d08b1fafc519df90544f775f8bd8c38 (patch) | |
tree | d7ae24497e7e0cc0d41a6f421d5fb143440090e0 /apps/files_sharing | |
parent | 8967602470bbdde9635b7f773d72325e39227c5f (diff) | |
download | nextcloud-server-8ca910976d08b1fafc519df90544f775f8bd8c38.tar.gz nextcloud-server-8ca910976d08b1fafc519df90544f775f8bd8c38.zip |
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>
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/lib/Updater.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/Updater.php b/apps/files_sharing/lib/Updater.php index ad194dde016..b110b2045f9 100644 --- a/apps/files_sharing/lib/Updater.php +++ b/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); |