diff --git a/lib/Controller/MainController.php b/lib/Controller/MainController.php index 256e9f0..a6b2e5f 100644 --- a/lib/Controller/MainController.php +++ b/lib/Controller/MainController.php @@ -54,21 +54,38 @@ class MainController extends Controller // OC_Util::addStyle($this->appName, 'table'); $params = array(); $params['aria2_running'] = $this->aria2->isRunning(); - $params['aria2_installed'] = $this->aria2->isInstalled(); - $params['aria2_bin'] = $this->aria2->getBin(); - $params['aria2_executable'] = $this->aria2->isExecutable(); - $params['youtube_installed'] = $this->youtube->isInstalled(); - $params['youtube_bin'] = $this->youtube->getBin(); - $params['youtube_executable'] = $this->youtube->isExecutable(); + $params['aria2_installed'] = $aria2_installed = $this->aria2->isInstalled(); + $params['aria2_bin'] = $aria2_bin = $this->aria2->getBin(); + $params['aria2_executable'] = $aria2_executable = $this->aria2->isExecutable(); + $params['youtube_installed'] = $youtube_installed = $this->youtube->isInstalled(); + $params['youtube_bin'] = $youtube_bin = $this->youtube->getBin(); + $params['youtube_executable'] = $youtube_executable = $this->youtube->isExecutable(); $params['ncd_hide_errors'] = $this->settings->get("ncd_hide_errors", false); $params['counter'] = $this->counters->getCounters(); + $params['python_installed'] = $python_installed = Helper::pythonInstalled(); + + $errors = []; + if ($aria2_installed && !$aria2_executable) { + array_push($errors, sprintf("aria2 is installed but don't have the right permissions.Please execute command sudo chmod 755 %s", $aria2_bin)); + } + + if ($youtube_installed && (!$youtube_executable || !@is_readable($youtube_bin))) { + array_push($errors, sprintf("youtube-dl is installed but don't have the right permissions.Please execute command sudo chmod 755 %s", $youtube_bin)); + } else if (!$youtube_installed) { + array_push($errors, "youtube-dl is not installed!"); + } + + if (!$python_installed) { + array_push($errors, "python is not installed!"); + } + $params['errors'] = $errors; $params['settings'] = json_encode([ - 'is_admin' =>\OC_User::isAdminUser($this->uid), + 'is_admin' => \OC_User::isAdminUser($this->uid), 'admin_url' => $this->urlGenerator->linkToRoute("settings.AdminSettings.index", ['section' => 'ncdownloader']), - 'personal_url' => $this->urlGenerator->linkToRoute("settings.PersonalSettings.index", ['section' => 'ncdownloader']), - 'ncd_hide_errors' => $params['ncd_hide_errors'], - ]); + 'personal_url' => $this->urlGenerator->linkToRoute("settings.PersonalSettings.index", ['section' => 'ncdownloader']), + 'ncd_hide_errors' => $params['ncd_hide_errors'], + ]); $response = new TemplateResponse($this->appName, 'Index', $params); return $response; diff --git a/lib/Tools/Aria2.php b/lib/Tools/Aria2.php index 2801a9d..1860e32 100644 --- a/lib/Tools/Aria2.php +++ b/lib/Tools/Aria2.php @@ -44,7 +44,7 @@ class Aria2 $this->bin = Helper::findBinaryPath('aria2c', __DIR__ . "/../../bin/aria2c"); } if ($this->isInstalled() && !$this->isExecutable()) { - chmod($this->bin, 755); + chmod($this->bin, 0744); } $this->setDownloadDir($dir); $this->setTorrentsDir($torrents_dir); diff --git a/lib/Tools/Helper.php b/lib/Tools/Helper.php index e992e63..7becd2a 100644 --- a/lib/Tools/Helper.php +++ b/lib/Tools/Helper.php @@ -209,8 +209,10 @@ class Helper $exeSniffer = new ExecutableFinder(); // Returns null if nothing is found $result = $exeSniffer->find($program, $default, $paths); - // store the value for 5 minutes - $memcache->set($program, $result, 300); + if ($result) { + // store the value for 5 minutes + $memcache->set($program, $result, 300); + } return $result; } @@ -324,4 +326,9 @@ class Helper return self::doSignal($pid, 9); } + public static function pythonInstalled() + { + return (bool) self::findBinaryPath('python'); + } + } diff --git a/lib/Tools/Youtube.php b/lib/Tools/Youtube.php index 174968f..ca5a4d9 100644 --- a/lib/Tools/Youtube.php +++ b/lib/Tools/Youtube.php @@ -34,7 +34,7 @@ class Youtube $this->bin = Helper::findBinaryPath('youtube-dl', __DIR__ . "/../../bin/youtube-dl"); } if ($this->isInstalled() && !$this->isExecutable()) { - chmod($this->bin, 755); + chmod($this->bin, 0744); } $this->setDownloadDir($downloadDir); if (!empty($settings)) { @@ -246,6 +246,11 @@ class Youtube return @is_executable($this->bin); } + public function isReadable() + { + return @is_readable($this->bin); + } + public function getBin() { return $this->bin; diff --git a/templates/Navigation.php b/templates/Navigation.php index 8c90758..b14c153 100644 --- a/templates/Navigation.php +++ b/templates/Navigation.php @@ -1,16 +1,5 @@