From 462c833add1560ccfb315e09aa83d328a48e1bfd Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Sun, 14 Jun 2015 09:16:34 +0100
Subject: [PATCH] only attempt to rsync if the source directory exists

---
 noblogsmv/main.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/noblogsmv/main.py b/noblogsmv/main.py
index 514cc3f..81b023c 100644
--- a/noblogsmv/main.py
+++ b/noblogsmv/main.py
@@ -93,9 +93,11 @@ def process_move_data(blog_id, value, progress):
     blog_dir = os.path.join(BLOGS_DIR, blog_id)
 
     if not dry_run:
+        # Only run rsync if the directory actually exists.
         cmd = sshcmd(
-            'root@%s' % value['old_host'], 'rsync', '-az',
-            '%s/' % blog_dir, 'root@%s:%s' % (value['new_host'], blog_dir))
+            'root@%s' % value['old_host'],
+            'test ! -d %s || rsync -a %s/ root@%s:%s/' % (
+                blog_dir, blog_dir, value['new_host'], blog_dir))
         log.debug('Calling %s', ' '.join(cmd))
         try:
             execute(cmd)
-- 
GitLab