Link new plugins when updating repos via admin/plugins

This commit is contained in:
Andrew Manning 2016-05-18 21:32:23 -04:00
parent c17b47518d
commit 77eb9bcfa0

View File

@ -1758,6 +1758,18 @@ class Admin extends \Zotlabs\Web\Controller {
$git = new GitRepo('sys', null, false, $repoName, $repoDir);
try {
if ($git->pull()) {
$files = array_diff(scandir($repoDir), array('.', '..'));
foreach ($files as $file) {
if (is_dir($repoDir . '/' . $file) && $file !== '.git') {
$source = '../extend/addon/' . $repoName . '/' . $file;
$target = realpath(__DIR__ . '/../../addon/') . '/' . $file;
unlink($target);
if (!symlink($source, $target)) {
logger('Error linking addons to /addon');
json_return_and_die(array('message' => 'Error linking addons to /addon', 'success' => false));
}
}
}
json_return_and_die(array('message' => 'Repo updated.', 'success' => true));
} else {
json_return_and_die(array('message' => 'Error updating addon repo.', 'success' => false));