diff --git a/module/admin/model.php b/module/admin/model.php index dca774f73e..0036e1c0c4 100755 --- a/module/admin/model.php +++ b/module/admin/model.php @@ -379,11 +379,13 @@ class adminModel extends model * @access public * @return bool */ - public function checkInternet(): bool + public function checkInternet($url = ''): bool { + if(empty($url)) $url = $this->config->admin->apiSite; + $timeout = 1; $curl = curl_init(); - curl_setopt($curl, CURLOPT_URL, $this->config->admin->apiSite); + curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_TIMEOUT, $timeout); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); diff --git a/module/repo/control.php b/module/repo/control.php index eff949b08d..4d9c2ad978 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -426,7 +426,12 @@ class repo extends control /* Get repo and synchronous commit. */ $repo = $this->repo->getByID($repoID); - if(in_array($repo->SCM, array('Git', 'Gitea', 'Gogs')) && !is_dir($repo->path)) return $this->sendError(sprintf($this->lang->repo->error->notFound, $repo->name, $repo->path), $this->repo->createLink('maintain')); + if($repo->SCM == 'Git' && !is_dir($repo->path)) return $this->sendError(sprintf($this->lang->repo->error->notFound, $repo->name, $repo->path), $this->repo->createLink('maintain')); + if($repo && substr($repo->path, 0, 4) == 'http') + { + if(!$this->loadModel('admin')->checkInternet($repo->path)) return $this->sendError($this->lang->repo->error->connect, true); + } + if(!$repo->synced) return $this->locate($this->repo->createLink('showSyncCommit', "repoID=$repoID&objectID=$objectID")); /* Set branch or tag for git. */