]> _ Git - cubist_util.git/commitdiff
wip #7387
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 13 Mar 2025 16:12:37 +0000 (17:12 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 13 Mar 2025 16:12:37 +0000 (17:12 +0100)
src/CommandLine/LFTP.php

index 2bbe5ab7c60b3219335c301f08d4be73b4e9378c..39afbb4606485755592c13ce3ca64d964bdcade1 100644 (file)
@@ -9,7 +9,7 @@ class LFTP extends CloneUserpassProgram
 {
     protected $_prog = '/usr/bin/lftp';
 
-    protected $_ftpTimeout = 120;
+    protected $_ftpTimeout = 20;
 
     /**
      * @var bool
@@ -47,9 +47,9 @@ class LFTP extends CloneUserpassProgram
     {
         parent::_preExecute();
         $commands = [
-            'set net:reconnect-interval-base 5',
+            'set net:reconnect-interval-base 1',
             'set net:timeout ' . $this->getFTPTimeout(),
-            'set net:max-retries 5',
+            'set net:max-retries 1',
             'set ftp:passive-mode ' . ($this->isPassiveMode() ? '1' : '0')
         ];
 
@@ -73,12 +73,16 @@ class LFTP extends CloneUserpassProgram
                 break;
         }
 
+        $fdest = $this->getFinalDest();
+        $cmd = [];
+        if ($fdest !== '/') {
+            $cmd[] = 'mkdir -p ' . $fdest;
+            $cmd[] = 'cd ' . $fdest;
+        }
+
         if (is_dir($this->getSrc())) {
-            $commands = array_merge($commands, [
-                'mkdir -p ' . $this->getFinalDest(),
-                'cd ' . $this->getFinalDest(),
-                'lcd ' . $this->getSrc(),
-            ]);
+            $cmd[] = 'lcd ' . $this->getSrc();
+            $commands = array_merge($commands, $cmd);
             $mirrorCmd = 'mirror --reverse --verbose --parallel=5';
             if ($this->getMirror()) {
                 $mirrorCmd .= ' --delete';
@@ -90,17 +94,14 @@ class LFTP extends CloneUserpassProgram
         } else {
             $filename = explode('/', $this->getSrc());
             $filename = end($filename);
-            $commands = array_merge($commands, [
-                'mkdir -p ' . $this->getFinalDest(),
-                'cd ' . $this->getFinalDest(),
-                'put ' . $this->getSrc()
-            ]);
+            $cmd[] = 'put ' . $this->getSrc();
+            $commands = array_merge($commands, $cmd);
             if ($this->isDryRun()) {
                 throw new \Exception("dry-run flag is incompatible for sending files");
             }
         }
 
-        $this->setArg('c', 'open ' . $this->getUsername() . ':' . $this->_escapePassword($this->getPassword()) . '@' . $this->getHost() . ':' . $this->getPort() . ' ' . implode(';', $commands));
+        $this->setArg('c', 'open ' . $this->getUsername() . ':' . $this->_escapePassword($this->getPassword()) . '@' . $this->getHost() . ':' . $this->getPort() . ';' . implode(';', $commands));
     }
 
     protected function _escapePassword($password)