Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Fix memory leak : reloading driverInstance may induce mem leaks. Make…
Browse files Browse the repository at this point in the history
… sure to do it only if necessary.
  • Loading branch information
cdujeu committed Mar 21, 2016
1 parent 7fcfd44 commit 87b5229
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 6 additions & 4 deletions core/src/plugins/action.share/class.ShareCenter.php
Expand Up @@ -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;
}

Expand Down
8 changes: 6 additions & 2 deletions core/src/plugins/action.share/class.ShareStore.php
Expand Up @@ -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){
Expand Down Expand Up @@ -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;

}

Expand Down

0 comments on commit 87b5229

Please sign in to comment.