This commit is contained in:
@ -3,6 +3,7 @@ namespace App\Rclone;
|
||||
|
||||
use Psr\Log\LoggerAwareTrait;
|
||||
use Psr\Log\NullLogger;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||
@ -45,13 +46,14 @@ class Rclone
|
||||
try
|
||||
{
|
||||
$version = $this->exec('--version');
|
||||
$this->version = explode("\n", $version)[0];
|
||||
}
|
||||
catch(ProcessFailedException $e)
|
||||
{
|
||||
throw new Exception("Check installation of rclone");
|
||||
}
|
||||
|
||||
$this->version = explode("\n", $version)[0];
|
||||
|
||||
|
||||
if (!\str_contains($this->version, 'rclone')) {
|
||||
throw new Exception("Rclone not recognized");
|
||||
@ -122,16 +124,23 @@ class Rclone
|
||||
$options
|
||||
)
|
||||
);
|
||||
$this->logger->info("Execute command", [$process->getCommandLine()]);
|
||||
if ($this->logger instanceof LoggerInterface) {
|
||||
$this->logger->info("Execute command", [$process->getCommandLine()]);
|
||||
}
|
||||
|
||||
$process->setTimeout(4*3600);
|
||||
$process->run();
|
||||
|
||||
// executes after the command finishes
|
||||
if (!$process->isSuccessful()) {
|
||||
$this->logger->error("Failed execution");
|
||||
if ($this->logger instanceof LoggerInterface) {
|
||||
$this->logger->error("Failed execution");
|
||||
}
|
||||
throw new ProcessFailedException($process);
|
||||
}
|
||||
$this->logger->info("Return code", [$process->getExitCode()]);
|
||||
if ($this->logger instanceof LoggerInterface) {
|
||||
$this->logger->info("Return code", [$process->getExitCode()]);
|
||||
}
|
||||
return $process->getOutput();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user