From 20d9f63918d3b2bd75853182063f43eb36d7cd8a Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Wed, 28 Apr 2021 13:58:55 +0200 Subject: Adjusts modules --- src/CopyModule.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/CopyModule.php') diff --git a/src/CopyModule.php b/src/CopyModule.php index 069f594..1f0b5c3 100644 --- a/src/CopyModule.php +++ b/src/CopyModule.php @@ -4,15 +4,17 @@ namespace PHPIAC\Modules; use PHPIAC\Connection; use PHPIAC\Module\Module; +use PHPIAC\Modules\Support\HandlesFiles; use PHPIAC\Modules\Support\HasPermissions; class CopyModule extends Module { - use HasPermissions; + use HasPermissions, HandlesFiles; protected string $src; protected string $dest; + protected bool $force = false; protected bool $remoteSrc = false; /** @@ -28,13 +30,17 @@ class CopyModule extends Module */ public function checkState(): bool { - return false; + if ($this->force) { + return false; + } + + return $this->fileExists($this->dest); } /** * @inheritDoc */ - public function getCommands(): array + public function execute(): void { if ($this->remoteSrc) { Connection::exec("sudo cp -r $this->src $this->dest"); @@ -44,7 +50,5 @@ class CopyModule extends Module } Connection::exec($this->getPermissions($this->dest)); - - return []; } } -- cgit v1.2.3