From 8fb9d5303b6055b6735792dd48618f7311874d08 Mon Sep 17 00:00:00 2001 From: soufiane Date: Tue, 30 Jan 2024 19:12:41 +0100 Subject: [PATCH] wip #6668 @5:00 --- src/CommandLine/LFTP.php | 33 +++++++++++++++++++++------------ src/CommandLine/Rclone.php | 2 +- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/CommandLine/LFTP.php b/src/CommandLine/LFTP.php index 9fbdca2..7784e98 100644 --- a/src/CommandLine/LFTP.php +++ b/src/CommandLine/LFTP.php @@ -42,19 +42,28 @@ class LFTP extends CloneUserpassProgram break; } - $commands = array_merge($commands, [ - 'mkdir -p ' . $this->getFinalDest(), - 'cd ' . $this->getFinalDest(), - 'lcd ' . $this->getSrc(), - ]); - $mirrorCmd = 'mirror --reverse --verbose --parallel=5'; - if ($this->getMirror()) { - $mirrorCmd .= ' --delete'; + if(is_dir($this->getSrc())) { + $commands = array_merge($commands, [ + 'mkdir -p ' . $this->getFinalDest(), + 'cd ' . $this->getFinalDest(), + 'lcd ' . $this->getSrc(), + ]); + $mirrorCmd = 'mirror --reverse --verbose --parallel=5'; + if ($this->getMirror()) { + $mirrorCmd .= ' --delete'; + } + if ($this->isDryRun()) { + $mirrorCmd .= ' --dry-run'; + } + $commands[] = $mirrorCmd; + } else { + $filename = explode('/',$this->getSrc()); + $filename = end($filename); + $commands = array_merge($commands, [ + 'put ' . $this->getSrc(), + 'rm ' . $filename + ]); } - if ($this->isDryRun()) { - $mirrorCmd .= ' --dry-run'; - } - $commands[] = $mirrorCmd; $this->setArg('c', 'open ftp://'.$this->getUsername().':'.$this->getPassword().'@'.$this->getHost().':'.$this->getPort().' '.implode(';', $commands)); } diff --git a/src/CommandLine/Rclone.php b/src/CommandLine/Rclone.php index d9372ba..3047620 100644 --- a/src/CommandLine/Rclone.php +++ b/src/CommandLine/Rclone.php @@ -34,7 +34,7 @@ class Rclone extends CloneUserpassProgram $dest = $this->getFinalDest(); break; default: - $dest = ':' . mb_strtolower($this->getProtocol()) . ':' . $this->getDest(); + $dest = ':' . mb_strtolower($this->getProtocol()) . ':' . rtrim($this->getDest(), '/').'/'; break; } $this->setManualArg($dest); -- 2.39.5