diff --git a/core/src/plugins/action.share/class.ShareCenter.php b/core/src/plugins/action.share/class.ShareCenter.php index ff95ce77cc..8952708215 100644 --- a/core/src/plugins/action.share/class.ShareCenter.php +++ b/core/src/plugins/action.share/class.ShareCenter.php @@ -897,11 +897,13 @@ public function updateNodeSharedData($oldNode=null, $newNode=null, $copy = false } } $shareStore = $this->getShareStore(); - $shareStore->moveSharesFromMetaRecursive($oldNode, $delete, $oldNode->getPath(), ($newNode != null ? $newNode->getPath() : null)); + $modifiedNodes = $shareStore->moveSharesFromMetaRecursive($oldNode, $delete, $oldNode->getPath(), ($newNode != null ? $newNode->getPath() : null)); // Force switching back to correct driver! - $oldNode->getRepository()->driverInstance = null; - $oldNode->setDriver(null); - $oldNode->getDriver(); + if($modifiedNodes > 0){ + $oldNode->getRepository()->driverInstance = null; + $oldNode->setDriver(null); + $oldNode->getDriver(); + } return; } diff --git a/core/src/plugins/action.share/class.ShareStore.php b/core/src/plugins/action.share/class.ShareStore.php index 6546f6759c..03f6af2f6f 100644 --- a/core/src/plugins/action.share/class.ShareStore.php +++ b/core/src/plugins/action.share/class.ShareStore.php @@ -485,21 +485,24 @@ public function deleteShare($type, $element, $keepRepository = false, $ignoreRep * @param string $oldPath * @param string $newPath * @param string|null $parentRepositoryPath + * @return int Number of nodes modified in different repositories */ public function moveSharesFromMetaRecursive($baseNode, $delete = false, $oldPath, $newPath, $parentRepositoryPath = null){ + $modifiedDifferentNodes = 0; // Find shares in children try{ $result = $this->getMetaManager()->collectSharesIncludingChildren($baseNode); }catch(Exception $e){ // Error while loading node, ignore - return; + return $modifiedDifferentNodes; } $basePath = $baseNode->getPath(); foreach($result as $relativePath => $metadata){ if($relativePath == "/") { $relativePath = ""; } + $modifiedDifferentNodes ++; $changeOldNode = new AJXP_Node("pydio://".$baseNode->getRepositoryId().$oldPath.$relativePath); foreach($metadata as $ownerId => $meta){ @@ -541,12 +544,13 @@ public function moveSharesFromMetaRecursive($baseNode, $delete = false, $oldPath } foreach($collectedRepositories as $sharedRepoId => $parentRepositoryPath){ - $this->moveSharesFromMetaRecursive(new AJXP_Node("pydio://".$sharedRepoId."/"), $delete, $changeOldNode->getPath(), $changeNewNode->getPath(), $parentRepositoryPath); + $modifiedDifferentNodes += $this->moveSharesFromMetaRecursive(new AJXP_Node("pydio://".$sharedRepoId."/"), $delete, $changeOldNode->getPath(), $changeNewNode->getPath(), $parentRepositoryPath); } } } + return $modifiedDifferentNodes; }