]> _ Git - cubist_util.git/commitdiff
wip #6668 @5:00
authorsoufiane <soufiane@cubedesigners.com>
Tue, 30 Jan 2024 18:12:41 +0000 (19:12 +0100)
committersoufiane <soufiane@cubedesigners.com>
Tue, 30 Jan 2024 18:12:41 +0000 (19:12 +0100)
src/CommandLine/LFTP.php
src/CommandLine/Rclone.php

index 9fbdca2682fbc79904faff01895f8b105f4e51ce..7784e98485dafe26192977a5dedc271f7fe11228 100644 (file)
@@ -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));
     }
index d9372ba37e23e5aeb9ee2eb80eb34f60ac7f78ba..304762036f04fb89b47f657c0e381f1f0cae8cdb 100644 (file)
@@ -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);