Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis Chemineau <louis@chmn.me>2022-03-31 13:08:42 +0300
committerLouis (Rebase PR Action) <artonge@users.noreply.github.com>2022-07-26 15:17:46 +0300
commit13e7ebbe4bfcf117c2d1ed7cc4758327c302bcab (patch)
treefc87bbf227fe4fdbf64e4f101fdd2bd3e6d9b633 /apps/files_sharing
parentce7b6ffed2186c6a1a46549669fb1f3cb4451114 (diff)
Change share owner when moving share out of share
Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/lib/Updater.php26
1 files changed, 14 insertions, 12 deletions
diff --git a/apps/files_sharing/lib/Updater.php b/apps/files_sharing/lib/Updater.php
index b110b2045f9..a1159cc3f58 100644
--- a/apps/files_sharing/lib/Updater.php
+++ b/apps/files_sharing/lib/Updater.php
@@ -38,7 +38,7 @@ class Updater {
*/
public static function renameHook($params) {
self::renameChildren($params['oldpath'], $params['newpath']);
- self::moveShareToShare($params['newpath']);
+ self::moveShareInOrOutOfShare($params['newpath']);
}
/**
@@ -51,7 +51,7 @@ class Updater {
*
* @param string $path
*/
- private static function moveShareToShare($path) {
+ private static function moveShareInOrOutOfShare($path): void {
$userFolder = \OC::$server->getUserFolder();
// If the user folder can't be constructed (e.g. link share) just return.
@@ -85,11 +85,6 @@ class Updater {
// Check if the destination is inside a share
$mountManager = \OC::$server->getMountManager();
$dstMount = $mountManager->find($src->getPath());
- if (!($dstMount instanceof \OCA\Files_Sharing\SharedMount)) {
- return;
- }
-
- $newOwner = $dstMount->getShare()->getShareOwner();
//Ownership is moved over
foreach ($shares as $share) {
@@ -101,13 +96,20 @@ class Updater {
continue;
}
- /** @var IShare $share */
- if (!($dstMount->getShare()->getPermissions() & Constants::PERMISSION_SHARE)) {
- $shareManager->deleteShare($share);
- continue;
+ if ($dstMount instanceof \OCA\Files_Sharing\SharedMount) {
+ if (!($dstMount->getShare()->getPermissions() & Constants::PERMISSION_SHARE)) {
+ $shareManager->deleteShare($share);
+ continue;
+ }
+ $newOwner = $dstMount->getShare()->getShareOwner();
+ $newPermissions = $share->getPermissions() & $dstMount->getShare()->getPermissions();
+ } else {
+ $newOwner = $userFolder->getOwner()->getUID();
+ $newPermissions = $share->getPermissions();
}
+
$share->setShareOwner($newOwner);
- $share->setPermissions($share->getPermissions() & $dstMount->getShare()->getPermissions());
+ $share->setPermissions($newPermissions);
$shareManager->updateShare($share);
}
}