Browse code

Apply include/exclude to destinations too, via mdomsch/s3cmd@268e7c3bd37cf60920025d556449fc1b93a1c590 Refs s3tools/s3cmd#109.

Dave Cole authored on 2013/04/12 03:30:28
Showing 1 changed files
... ...
@@ -621,6 +621,14 @@ def cmd_info(args):
621 621
             else:
622 622
                 raise
623 623
 
624
+def filedicts_to_keys(*args):
625
+    keys = set()
626
+    for a in args:
627
+        keys.update(a.keys())
628
+    keys = list(keys)
629
+    keys.sort()
630
+    return keys
631
+
624 632
 def cmd_sync_remote2remote(args):
625 633
     def _do_deletes(s3, dst_list):
626 634
         # Delete items in destination that are not in source
... ...
@@ -646,7 +654,8 @@ def cmd_sync_remote2remote(args):
646 646
 
647 647
     info(u"Found %d source files, %d destination files" % (src_count, dst_count))
648 648
 
649
-    src_list, exclude_list = filter_exclude_include(src_list)
649
+    src_list, src_exclude_list = filter_exclude_include(src_list)
650
+    dst_list, dst_exclude_list = filter_exclude_include(dst_list)
650 651
 
651 652
     src_list, dst_list, update_list, copy_pairs = compare_filelists(src_list, dst_list, src_remote = True, dst_remote = True, delay_updates = cfg.delay_updates)
652 653
 
... ...
@@ -663,7 +672,8 @@ def cmd_sync_remote2remote(args):
663 663
         update_list[key]['target_uri'] = destination_base + key
664 664
 
665 665
     if cfg.dry_run:
666
-        for key in exclude_list:
666
+        keys = filedicts_to_keys(src_exclude_list, dst_exclude_list)
667
+        for key in keys:
667 668
             output(u"exclude: %s" % unicodise(key))
668 669
         if cfg.delete_removed:
669 670
             for key in dst_list:
... ...
@@ -734,7 +744,8 @@ def cmd_sync_remote2local(args):
734 734
 
735 735
     info(u"Found %d remote files, %d local files" % (remote_count, local_count))
736 736
 
737
-    remote_list, exclude_list = filter_exclude_include(remote_list)
737
+    remote_list, src_exclude_list = filter_exclude_include(remote_list)
738
+    local_list, dst_exclude_list = filter_exclude_include(local_list)
738 739
 
739 740
     remote_list, local_list, update_list, copy_pairs = compare_filelists(remote_list, local_list, src_remote = True, dst_remote = False, delay_updates = cfg.delay_updates)
740 741
 
... ...
@@ -766,7 +777,8 @@ def cmd_sync_remote2local(args):
766 766
     _set_local_filename(update_list, destination_base)
767 767
 
768 768
     if cfg.dry_run:
769
-        for key in exclude_list:
769
+        keys = filedicts_to_keys(src_exclude_list, dst_exclude_list)
770
+        for key in keys:
770 771
             output(u"exclude: %s" % unicodise(key))
771 772
         if cfg.delete_removed:
772 773
             for key in local_list:
... ...
@@ -1072,7 +1084,8 @@ def cmd_sync_local2remote(args):
1072 1072
 
1073 1073
         info(u"Found %d local files, %d remote files" % (local_count, remote_count))
1074 1074
 
1075
-        local_list, exclude_list = filter_exclude_include(local_list)
1075
+        local_list, src_exclude_list = filter_exclude_include(local_list)
1076
+        remote_list, dst_exclude_list = filter_exclude_include(remote_list)
1076 1077
 
1077 1078
         if single_file_local and len(local_list) == 1 and len(remote_list) == 1:
1078 1079
             ## Make remote_key same as local_key for comparison if we're dealing with only one file
... ...
@@ -1094,7 +1107,8 @@ def cmd_sync_local2remote(args):
1094 1094
         _set_remote_uri(update_list, destination_base, single_file_local)
1095 1095
 
1096 1096
         if cfg.dry_run:
1097
-            for key in exclude_list:
1097
+            keys = filedicts_to_keys(src_exclude_list, dst_exclude_list)
1098
+            for key in keys:
1098 1099
                 output(u"exclude: %s" % unicodise(key))
1099 1100
             for key in local_list:
1100 1101
                 output(u"upload: %s -> %s" % (local_list[key]['full_name_unicode'], local_list[key]['remote_uri']))