From c861408977aaa105e9e301fa26d231b261bf312a Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 20 Dec 2024 12:43:44 +0100 Subject: [PATCH] wait #7239 @3 --- src/Server/SFTP.php | 32 +++++++++++++++++++++++++++++++- src/Transfer/Driver.php | 7 ++++--- src/Transfer/FTP.php | 6 ++++-- src/Transfer/Local.php | 5 ++++- src/Transfer/S3.php | 3 +++ src/Transfer/SFTP.php | 12 ++++++++---- 6 files changed, 54 insertions(+), 11 deletions(-) diff --git a/src/Server/SFTP.php b/src/Server/SFTP.php index b653056..06992f7 100644 --- a/src/Server/SFTP.php +++ b/src/Server/SFTP.php @@ -66,4 +66,34 @@ class SFTP implements IServer { // TODO: Implement makeURL() method. } -} \ No newline at end of file + + public function getRegion() + { + // TODO: Implement getRegion() method. + } + + public function getAccessKey() + { + // TODO: Implement getAccessKey() method. + } + + public function getSecret() + { + // TODO: Implement getSecret() method. + } + + public function getEndpoint() + { + // TODO: Implement getEndpoint() method. + } + + public function getBucket() + { + // TODO: Implement getBucket() method. + } + + public function getS3Provider() + { + // TODO: Implement getS3Provider() method. + } +} diff --git a/src/Transfer/Driver.php b/src/Transfer/Driver.php index 0561b16..ec7cd96 100644 --- a/src/Transfer/Driver.php +++ b/src/Transfer/Driver.php @@ -12,10 +12,11 @@ abstract class Driver * @var IServer */ protected $_server; + public $checkConnection = true; - public function __construct(IServer $server) + public function __construct(IServer $server, $checkConnection = true) { - + $this->checkConnection = $checkConnection; $this->setServer($server); } @@ -71,4 +72,4 @@ abstract class Driver { return $this->synchronizeFiles($source, $dest); } -} \ No newline at end of file +} diff --git a/src/Transfer/FTP.php b/src/Transfer/FTP.php index 9bfbaab..f15cb5e 100644 --- a/src/Transfer/FTP.php +++ b/src/Transfer/FTP.php @@ -34,7 +34,9 @@ class FTP extends Driver public function checkConnexion($data = []) { - + if(!$this->checkConnection){ + return true; + } $data['port'] = $data['port'] ?? $this->port; $data = [ 'username' => $data['username'] ?? $this->getServer()->getUsername(), @@ -86,4 +88,4 @@ class FTP extends Driver $filepath = explode('/', $file); return end($filepath); } -} \ No newline at end of file +} diff --git a/src/Transfer/Local.php b/src/Transfer/Local.php index beb00a2..eb3866e 100644 --- a/src/Transfer/Local.php +++ b/src/Transfer/Local.php @@ -77,6 +77,9 @@ class Local extends Driver public function checkConnexion($data = []) { + if(!$this->checkConnection){ + return true; + } if (file_exists($this->getRootPath() . 'status')) { return true; } else { @@ -84,4 +87,4 @@ class Local extends Driver } } -} \ No newline at end of file +} diff --git a/src/Transfer/S3.php b/src/Transfer/S3.php index 798abe7..ce8ba57 100644 --- a/src/Transfer/S3.php +++ b/src/Transfer/S3.php @@ -23,6 +23,9 @@ class S3 extends Driver public function checkConnexion($data = []) { + if(!$this->checkConnection){ + return true; + } $client = $this->createClient($data); $test = 'test' . time() . '-' . rand(1, 1000000); diff --git a/src/Transfer/SFTP.php b/src/Transfer/SFTP.php index a3bce4c..54c1ee1 100644 --- a/src/Transfer/SFTP.php +++ b/src/Transfer/SFTP.php @@ -4,7 +4,6 @@ namespace Cubist\Net\Transfer; use Cubist\Util\CommandLine\Rclone; use Cubist\Util\Files\Files; -use Illuminate\Support\Facades\Log; class SFTP extends Driver { @@ -19,9 +18,10 @@ class SFTP extends Driver const DEFAULT_PORT = 22; - public static function getInstance($host, $username, $password, $path, $port = self::DEFAULT_PORT) + public static function getInstance($host, $username, $password, $path, $port = self::DEFAULT_PORT, $checkConnection = true) { - return new SFTP(new \Cubist\Net\Server\SFTP($host, $username, $password, $path, $port)); + + return new SFTP(new \Cubist\Net\Server\SFTP($host, $username, $password, $path, $port), $checkConnection); } protected function synchronizeFiles($source, $dest, $mirror = false, $dryrun = false) @@ -33,11 +33,15 @@ class SFTP extends Driver $rclone->setMirror($mirror); $rclone->setDryRun($dryrun); $rclone->execute(); + $rclone->debug(); return $rclone; } public function checkConnexion($data = []) { + if (!$this->checkConnection) { + return true; + } $connection = null; $data = [ @@ -90,4 +94,4 @@ class SFTP extends Driver $filepath = explode('/', $file); return end($filepath); } -} \ No newline at end of file +} -- 2.39.5