improved user experience for novice user(including support for standalone aria2c and ytdl binaries);support for snap installation;close #19

This commit is contained in:
huangjx
2022-02-21 15:50:42 +08:00
parent 20b3e25369
commit 8e5ebdd8e7
11 changed files with 88 additions and 18 deletions

View File

@@ -38,10 +38,10 @@ class Aria2
);
//turn keys in $options into variables
extract($options);
if (isset($binary) && @is_executable($binary)) {
if (isset($binary) && $this->isExecutable($binary)) {
$this->bin = $binary;
} else {
$this->bin = Helper::findBinaryPath('aria2c');
$this->bin = Helper::findBinaryPath('aria2c', __DIR__ . "/../../bin/aria2c");
}
$this->setDownloadDir($dir);
$this->setTorrentsDir($torrents_dir);
@@ -379,17 +379,27 @@ class Aria2
}
public function isInstalled()
{
return (bool) (isset($this->bin) && @is_executable($this->bin));
return @is_file($this->bin);
}
public function isExecutable()
{
return @is_executable($this->bin);
}
public function isRunning()
{
$resp = $this->getSessionInfo();
return (bool) $resp;
}
public function getBin()
{
return $this->bin;
}
public function stop()
{
$resp = $this->shutdown();
sleep(1);
sleep(3);
return $resp ?? null;
}
private function confTemplate()