fixed some duplicate code

This commit is contained in:
huangjx
2022-04-23 00:13:49 +08:00
parent d0598e71fd
commit 384cd08330

View File

@@ -97,10 +97,14 @@ class Aria2
private function configure()
{
if (!is_dir($this->confDir)) {
if ($this->confDir && !is_dir($this->confDir)) {
mkdir($this->confDir, 0755, true);
}
if (!is_dir($dir = $this->getDownloadDir())) {
$dir = "";
if ($dir = $this->getDownloadDir() && !is_dir($dir)) {
mkdir($dir, 0755, true);
}
if ($dir = $this->getTorrentsDir() && !is_dir($dir)) {
mkdir($dir, 0755, true);
}
$this->followTorrent(true);
@@ -123,9 +127,6 @@ class Aria2
public function setTorrentsDir($dir)
{
$this->torrentsDir = $dir;
if (!is_dir($dir)) {
mkdir($dir, 0755, true);
}
return $this;
}
public function getTorrentsDir()
@@ -136,9 +137,6 @@ class Aria2
{
$this->setOption('dir', $dir);
$this->downloadDir = $dir;
if (!is_dir($dir)) {
mkdir($dir, 0755, true);
}
return $this;
}
public function getDownloadDir()