From 78b40e6363d422727bb716f5e72983291c75d217 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Tue, 10 May 2016 06:28:00 -0400 Subject: Delete existing repo if the new one has a different URL. Fixed bug that could cause repeated installation. --- Zotlabs/Module/Admin.php | 9 +++++++++ view/tpl/admin_plugins.tpl | 12 ++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Zotlabs/Module/Admin.php b/Zotlabs/Module/Admin.php index 63f3e77f0..1b98a2ced 100644 --- a/Zotlabs/Module/Admin.php +++ b/Zotlabs/Module/Admin.php @@ -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) { diff --git a/view/tpl/admin_plugins.tpl b/view/tpl/admin_plugins.tpl index 3265a534c..186cb052d 100755 --- a/view/tpl/admin_plugins.tpl +++ b/view/tpl/admin_plugins.tpl @@ -50,7 +50,12 @@ {{$newRepoModal}}