Delete existing repo if the new one has a different URL. Fixed bug that could cause repeated installation.

This commit is contained in:
Andrew Manning
2016-05-10 06:28:00 -04:00
parent 45c19e365d
commit 78b40e6363
2 changed files with 17 additions and 4 deletions

View File

@@ -1822,6 +1822,15 @@ class Admin extends \Zotlabs\Web\Controller {
// clone the repo if new automatically
$git = new GitRepo('sys', $repoURL, true, $repoName, $repoDir);
$remotes = $git->git->remote();
$fetchURL = $remotes['origin']['fetch'];
if($fetchURL !== $git->url) {
if(rrmdir($repoDir)) {
$git = new GitRepo('sys', $repoURL, true, $repoName, $repoDir);
} else {
json_return_and_die(array('message' => 'Error deleting existing addon repo.', 'success' => false));
}
}
$repo = $git->probeRepo();
$repo['readme'] = $repo['manifest'] = null;
foreach ($git->git->tree('master') as $object) {