@@ -38,7 +38,7 @@ class Updater {
3838 */
3939 public static function renameHook ($ params ) {
4040 self ::renameChildren ($ params ['oldpath ' ], $ params ['newpath ' ]);
41- self ::moveShareToShare ($ params ['newpath ' ]);
41+ self ::moveShareInOrOutOfShare ($ params ['newpath ' ]);
4242 }
4343
4444 /**
@@ -51,7 +51,7 @@ public static function renameHook($params) {
5151 *
5252 * @param string $path
5353 */
54- private static function moveShareToShare ($ path ) {
54+ private static function moveShareInOrOutOfShare ($ path ) {
5555 $ userFolder = \OC ::$ server ->getUserFolder ();
5656
5757 // If the user folder can't be constructed (e.g. link share) just return.
@@ -85,11 +85,12 @@ private static function moveShareToShare($path) {
8585 // Check if the destination is inside a share
8686 $ mountManager = \OC ::$ server ->getMountManager ();
8787 $ dstMount = $ mountManager ->find ($ src ->getPath ());
88- if (!($ dstMount instanceof \OCA \Files_Sharing \SharedMount)) {
89- return ;
88+ if ($ dstMount instanceof \OCA \Files_Sharing \SharedMount) {
89+ $ newOwner = $ dstMount ->getShare ()->getShareOwner ();
90+ } else {
91+ $ newOwner = $ userFolder ->getOwner ()->getUID ();
9092 }
9193
92- $ newOwner = $ dstMount ->getShare ()->getShareOwner ();
9394
9495 //Ownership is moved over
9596 foreach ($ shares as $ share ) {
@@ -101,13 +102,18 @@ private static function moveShareToShare($path) {
101102 continue ;
102103 }
103104
104- /** @var IShare $share */
105- if (!($ dstMount ->getShare ()->getPermissions () & Constants::PERMISSION_SHARE )) {
106- $ shareManager ->deleteShare ($ share );
107- continue ;
105+ if ($ dstMount instanceof \OCA \Files_Sharing \SharedMount) {
106+ if (!($ dstMount ->getShare ()->getPermissions () & Constants::PERMISSION_SHARE )) {
107+ $ shareManager ->deleteShare ($ share );
108+ continue ;
109+ }
110+ $ newPermissions = $ share ->getPermissions () & $ dstMount ->getShare ()->getPermissions ();
111+ } else {
112+ $ newPermissions = $ share ->getPermissions ();
108113 }
114+
109115 $ share ->setShareOwner ($ newOwner );
110- $ share ->setPermissions ($ share -> getPermissions () & $ dstMount -> getShare ()-> getPermissions () );
116+ $ share ->setPermissions ($ newPermissions );
111117 $ shareManager ->updateShare ($ share );
112118 }
113119 }
0 commit comments