From 19247df94c195d312aa280a93ab6623e0c6779e5 Mon Sep 17 00:00:00 2001 From: Matteo Contri Date: Fri, 20 Jun 2014 15:33:15 +0200 Subject: [PATCH 1/2] add options to preserve files on destination directory --- Services/FileManager.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Services/FileManager.php b/Services/FileManager.php index e74a166..293a569 100644 --- a/Services/FileManager.php +++ b/Services/FileManager.php @@ -109,7 +109,14 @@ public function syncFiles($options = array()) throw new \Exception("to_folder does not exist"); } $result = null; - system("rsync -a --delete " . escapeshellarg($from . '/') . " " . escapeshellarg($to), $result); + if (isset($options['preserve_to_files']) && $options['preserve_to_files']) + { + system("rsync -a" . escapeshellarg($from . '/') . " " . escapeshellarg($to), $result); + } + else + { + system("rsync -a --delete " . escapeshellarg($from . '/') . " " . escapeshellarg($to), $result); + } if ($result !== 0) { throw new \Exception("Sync failed"); From a4af42f0462f484d440eb79f2c0c634092df9bba Mon Sep 17 00:00:00 2001 From: Matteo Contri Date: Thu, 10 Jul 2014 12:39:59 +0200 Subject: [PATCH 2/2] improved rsync options and avoid space problem for parameters --- Services/FileManager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Services/FileManager.php b/Services/FileManager.php index 293a569..eb6f47c 100644 --- a/Services/FileManager.php +++ b/Services/FileManager.php @@ -111,11 +111,11 @@ public function syncFiles($options = array()) $result = null; if (isset($options['preserve_to_files']) && $options['preserve_to_files']) { - system("rsync -a" . escapeshellarg($from . '/') . " " . escapeshellarg($to), $result); + system(sprintf("rsync -rpgo %s/ %s", escapeshellarg($from . '/'), escapeshellarg($to)), $result); } else { - system("rsync -a --delete " . escapeshellarg($from . '/') . " " . escapeshellarg($to), $result); + system(sprintf("rsync -rpgo --delete %s/ %s", escapeshellarg($from . '/'), escapeshellarg($to)), $result); } if ($result !== 0) {