Quality of life things.
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Build and test / requirements (push) Failing after 3m48s
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Build and test / requirements (push) Failing after 3m48s
This commit is contained in:
@ -34,13 +34,13 @@ class Rclone
|
||||
$this->rclonePath = $rclonePath;
|
||||
|
||||
$process = $this->exec('--version');
|
||||
if (!$process->isSuccessful()) {
|
||||
if (! $process->isSuccessful()) {
|
||||
throw new Exception("Check installation of rclone");
|
||||
}
|
||||
|
||||
$this->version = explode("\n", $process->getOutput())[0];
|
||||
|
||||
if (!\str_contains($this->version, 'rclone')) {
|
||||
if (! \str_contains($this->version, 'rclone')) {
|
||||
throw new Exception("rclone not recognized");
|
||||
}
|
||||
}
|
||||
@ -66,12 +66,14 @@ class Rclone
|
||||
{
|
||||
$process = $this->exec('size', ['--json', $path]);
|
||||
|
||||
if (!$process->isSuccessful()) {
|
||||
if (! $process->isSuccessful()) {
|
||||
throw new Exception($process->getErrorOutput());
|
||||
}
|
||||
|
||||
/** @var array{bytes: int} */
|
||||
$output = json_decode($process->getOutput(), true);
|
||||
/**
|
||||
* @var array{bytes: int}
|
||||
*/
|
||||
$output = json_decode($process->getOutput(), TRUE);
|
||||
return $output['bytes'];
|
||||
}
|
||||
|
||||
@ -82,9 +84,9 @@ class Rclone
|
||||
* @param $dest Destination mount and path
|
||||
* @param string[] $additionalOptions Additional options
|
||||
*/
|
||||
public function copy(string $src, string $dest, array $additionalOptions = array()): void
|
||||
public function copy(string $src, string $dest, array $additionalOptions = []): void
|
||||
{
|
||||
$options = array();
|
||||
$options = [];
|
||||
|
||||
$options[] = $src;
|
||||
$options[] = $dest;
|
||||
@ -95,7 +97,7 @@ class Rclone
|
||||
}
|
||||
|
||||
$process = $this->exec('copy', $options);
|
||||
if (!$process->isSuccessful()) {
|
||||
if (! $process->isSuccessful()) {
|
||||
throw new Exception($process->getErrorOutput());
|
||||
}
|
||||
}
|
||||
@ -108,7 +110,7 @@ class Rclone
|
||||
*
|
||||
* @return Process Instance.
|
||||
*/
|
||||
private function exec(string $command, array $options = array()): Process
|
||||
private function exec(string $command, array $options = []): Process
|
||||
{
|
||||
$process = new Process(
|
||||
array_merge(
|
||||
@ -124,7 +126,7 @@ class Rclone
|
||||
$process->run();
|
||||
|
||||
// executes after the command finishes
|
||||
if (!$process->isSuccessful()) {
|
||||
if (! $process->isSuccessful()) {
|
||||
$this->logger->error("Failed execution");
|
||||
}
|
||||
$this->logger->info("Return code", [$process->getExitCode()]);
|
||||
|
Reference in New Issue
Block a user