]> _ Git - cubist_net.git/commitdiff
wip #5700 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 27 Jan 2023 14:43:25 +0000 (15:43 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 27 Jan 2023 14:43:25 +0000 (15:43 +0100)
src/Transfer/Driver.php
src/Transfer/FTP.php
src/Transfer/Local.php
src/Transfer/SFTP.php

index caa42e86102b9d159c8d1e8e5213009a50f8bab3..53c1d301c73cb525da4f273eeceeb7ab79b022f6 100644 (file)
@@ -38,11 +38,16 @@ abstract class Driver {
                return Text::str2URL($path, '-', true);
        }
 
+       protected function _destPath($path) {
+               return self::_cleanInstallDir($path);
+       }
+
        /**
         * @param $source string
         * @param $dest string
         * @param $mirror bool
+        * @param $dryrun bool
         * @return CommandLine
         */
-       abstract public function copy($source, $dest, $mirror = false);
+       abstract public function copy($source, $dest, $mirror = false, $dryrun = false);
 }
\ No newline at end of file
index 892e1bba07dd38b1a34c0bb7c000303da7304f8d..8de4ec92a7c3c2b18ec216eff77b7d3ff8739a9a 100644 (file)
@@ -2,9 +2,18 @@
 
 namespace Cubist\Net\Transfer;
 
-class FTP extends Driver {
+use Cubist\Util\CommandLine\LFTP;
+use Cubist\Util\CommandLine\Rclone;
 
-       public function copy($source, $dest, $mirror = false) {
-               // TODO: Implement copy() method.
+class FTP extends Driver {
+       public function copy($source, $dest, $mirror = false, $dryrun = false) {
+               $lftp = new LFTP();
+               $lftp->setSrc($source);
+               $lftp->setDest($dest);
+               $lftp->setMirror($mirror);
+               $lftp->setServer($this->getServer());
+               $lftp->setDryRun($dryrun);
+               $lftp->execute();
+               return $lftp;
        }
 }
\ No newline at end of file
index 3d8b5f5b48e758835d7d248e2c0f8704d928341f..557b75be92153d42b55edc07ae0fd1cbe9f76a75 100644 (file)
@@ -36,11 +36,10 @@ class Local extends Driver {
                return rtrim($this->getBasePath(), '/') . '/' . self::_cleanInstallDir($path) . '/';
        }
 
-       public function copy($source, $dest, $mirror = false) {
-               $destPath = $this->_destPath($dest);
-               $rsync = new Rsync($source, $destPath);
+       public function copy($source, $dest, $mirror = false, $dryrun = false) {
+               $rsync = new Rsync($source, $dest);
                $rsync->setMirror($mirror);
-               $rsync->setDryRun(true);
+               $rsync->setDryRun($dryrun);
                $rsync->execute();
                return $rsync;
        }
index 7b7607fabe03ef94dc5c6bb90129fdfaa666a3db..7b46af377af9a7fc24dd87a4d062abe102ef45f5 100644 (file)
@@ -7,21 +7,13 @@ use Cubist\Util\CommandLine\Rsync;
 
 class SFTP extends Driver {
 
-       public function copy($source, $dest, $mirror = false) {
-               $server=$this->getServer();
-
-               $destPath = $this->_destPath($dest);
+       public function copy($source, $dest, $mirror = false, $dryrun = false) {
                $rclone = new Rclone();
-               $rclone->setProtocol('sftp');
+               $rclone->setServer($this->getServer());
                $rclone->setSrc($source);
-               $rclone->setDest($destPath);
+               $rclone->setDest($dest);
                $rclone->setMirror($mirror);
-               $rclone->setProtocol('sftp');
-               $rclone->addRcloneArg('sftp-host',$server->getHost());
-               $rclone->addRcloneArg('sftp-port',$server->getPort());
-               $rclone->addRcloneArg('sftp-user',$server->getUsername());
-               $rclone->addRcloneArg('sftp-pass',$server->getPassword());
-               $rclone->setDryRun(true);
+               $rclone->setDryRun($dryrun);
                $rclone->execute();
                return $rclone;
        }