From 3f33729b4be233130564dda05f39f0523f5cd141 Mon Sep 17 00:00:00 2001 From: Jens True Date: Tue, 1 Apr 2025 14:09:39 +0000 Subject: [PATCH] Push update. --- composer.json | 2 +- src/App.php | 1 + src/CommandBackup.php | 2 +- src/Rclone/Rclone.php | 9 ++++++++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 8d40c47..3799380 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ "@analyze-psalm", "@analyze-phpcs" ], - "analyze-yaml": "vendor/bin/yaml-lint *.yml *.yaml *.json", + "analyze-yaml": "vendor/bin/yaml-lint .", "analyze-phpmd": "phpmd src,tests text cleancode,codesize,controversial,design,naming,unusedcode", "analyze-phpstan":"phpstan", "analyze-psalm": "psalm --no-cache", diff --git a/src/App.php b/src/App.php index 6f3804f..6f20254 100644 --- a/src/App.php +++ b/src/App.php @@ -35,6 +35,7 @@ final class App $this->config = new Configuration([ 'rclone' => Expect::structure([ 'path' => Expect::string()->default('rclone'), + 'config' => Expect::string()->default(''), 'options' => Expect::arrayOf('string', 'string') ]), 'backup' => Expect::arrayOf(Expect::structure([ diff --git a/src/CommandBackup.php b/src/CommandBackup.php index 3eb733f..a4e0689 100644 --- a/src/CommandBackup.php +++ b/src/CommandBackup.php @@ -64,7 +64,7 @@ final class CommandBackup extends Command return Command::FAILURE; } - $rclone = new Rclone($app->getLogger()->withName('rclone'), (string)$app->getConfig('rclone.path')); + $rclone = new Rclone($app->getLogger()->withName('rclone'), (string)$app->getConfig('rclone.path'), (string)$app->getConfig('rclone.config')); $notification = new Notification(); /** diff --git a/src/Rclone/Rclone.php b/src/Rclone/Rclone.php index 373643d..e79d113 100644 --- a/src/Rclone/Rclone.php +++ b/src/Rclone/Rclone.php @@ -28,8 +28,9 @@ final class Rclone * But the path can be configured to be absolute. * * @param string $rclonePath Relative or absolute path + * @param string $rcloneConfig Relative or absolute path to the rclone config file */ - public function __construct(protected LoggerInterface $logger, protected string $rclonePath = "rclone") + public function __construct(protected LoggerInterface $logger, protected string $rclonePath = "rclone", protected string $rcloneConfig = '') { $this->rclonePath = $rclonePath; @@ -112,9 +113,15 @@ final class Rclone */ private function exec(string $command, array $options = []): Process { + $rcloneconfig = []; + if ($this->rcloneConfig != '') { + $rcloneconfig = ['--config', $this->rcloneConfig]; + } + $process = new Process( array_merge( [$this->rclonePath], + $rcloneconfig, [$command], $options )