From 525fc1c333ca2a0f48a71379620956286e4d5480 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 13 Mar 2025 17:12:37 +0100 Subject: [PATCH] wip #7387 --- src/CommandLine/LFTP.php | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/CommandLine/LFTP.php b/src/CommandLine/LFTP.php index 2bbe5ab..39afbb4 100644 --- a/src/CommandLine/LFTP.php +++ b/src/CommandLine/LFTP.php @@ -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) -- 2.39.5