We were looking at the wrong (post-compare) list lengths, rather than
the original (discovered by walk) list lengths. And we weren't
checking to see if we had any files to delete, or not, before issuing
the "cowardly" message. So for a "null" (no files to transfer) sync
run, we would emit the message. That's wrong.
This patch fixes both problems:
1) it uses the discovered source file count. If nonzero, we will not
emit the message.
2) it looks at the count of files to delete. If zero, we will not
emit the message.
... | ... |
@@ -648,6 +648,7 @@ def cmd_sync_remote2remote(args): |
648 | 648 |
dst_list = fetch_remote_list(destination_base, recursive = True, require_attribs = True) |
649 | 649 |
|
650 | 650 |
src_count = len(src_list) |
651 |
+ orig_src_count = src_count |
|
651 | 652 |
dst_count = len(dst_list) |
652 | 653 |
|
653 | 654 |
info(u"Found %d source files, %d destination files" % (src_count, dst_count)) |
... | ... |
@@ -684,7 +685,7 @@ def cmd_sync_remote2remote(args): |
684 | 684 |
if len(copy_pairs) > 0: |
685 | 685 |
cfg.delete_after = True |
686 | 686 |
|
687 |
- if cfg.delete_removed and src_count + len(copy_pairs) == 0 and not cfg.force: |
|
687 |
+ if cfg.delete_removed and orig_src_count == 0 and len(dst_list) and not cfg.force: |
|
688 | 688 |
warning(u"delete: cowardly refusing to delete because no source files were found. Use --force to override.") |
689 | 689 |
cfg.delete_removed = False |
690 | 690 |
|
... | ... |
@@ -744,6 +745,7 @@ def cmd_sync_remote2local(args): |
744 | 744 |
|
745 | 745 |
local_count = len(local_list) |
746 | 746 |
remote_count = len(remote_list) |
747 |
+ orig_remote_count = remote_count |
|
747 | 748 |
|
748 | 749 |
info(u"Found %d remote files, %d local files" % (remote_count, local_count)) |
749 | 750 |
|
... | ... |
@@ -797,7 +799,7 @@ def cmd_sync_remote2local(args): |
797 | 797 |
if len(copy_pairs) > 0: |
798 | 798 |
cfg.delete_after = True |
799 | 799 |
|
800 |
- if cfg.delete_removed and remote_count + len(copy_pairs) == 0 and not cfg.force: |
|
800 |
+ if cfg.delete_removed and orig_remote_count == 0 and len(local_list) and not cfg.force: |
|
801 | 801 |
warning(u"delete: cowardly refusing to delete because no source files were found. Use --force to override.") |
802 | 802 |
cfg.delete_removed = False |
803 | 803 |
|
... | ... |
@@ -1088,6 +1090,7 @@ def cmd_sync_local2remote(args): |
1088 | 1088 |
remote_list = fetch_remote_list(destination_base, recursive = True, require_attribs = True) |
1089 | 1089 |
|
1090 | 1090 |
local_count = len(local_list) |
1091 |
+ orig_local_count = local_count |
|
1091 | 1092 |
remote_count = len(remote_list) |
1092 | 1093 |
|
1093 | 1094 |
info(u"Found %d local files, %d remote files" % (local_count, remote_count)) |
... | ... |
@@ -1134,7 +1137,7 @@ def cmd_sync_local2remote(args): |
1134 | 1134 |
if len(copy_pairs) > 0: |
1135 | 1135 |
cfg.delete_after = True |
1136 | 1136 |
|
1137 |
- if cfg.delete_removed and local_count + update_count + copy_count == 0 and not cfg.force: |
|
1137 |
+ if cfg.delete_removed and orig_local_count == 0 and len(remote_list) and not cfg.force: |
|
1138 | 1138 |
warning(u"delete: cowardly refusing to delete because no source files were found. Use --force to override.") |
1139 | 1139 |
cfg.delete_removed = False |
1140 | 1140 |
|