We can't hardlink only based on MD5. That would for example make
all empty files hardlinked together.
For now we will just copy locally instead of hardlink.
... | ... |
@@ -865,10 +865,10 @@ def cmd_sync_remote2local(args): |
865 | 865 |
seq, total_size = _download(remote_list, seq, remote_count + update_count, total_size, dir_cache) |
866 | 866 |
seq, total_size = _download(update_list, seq, remote_count + update_count, total_size, dir_cache) |
867 | 867 |
|
868 |
- failed_hardlink_list = local_hardlink(copy_pairs, destination_base) |
|
869 |
- _set_local_filename(failed_hardlink_list, destination_base) |
|
870 |
- seq, total_size = _download(failed_hardlink_list, seq, len(failed_hardlink_list) + remote_count + update_count, total_size, dir_cache) |
|
871 |
- |
|
868 |
+ failed_copy_list = local_copy(copy_pairs, destination_base) |
|
869 |
+ _set_local_filename(failed_copy_list, destination_base) |
|
870 |
+ seq, total_size = _download(failed_copy_list, seq, len(failed_copy_list) + remote_count + update_count, total_size, dir_cache) |
|
871 |
+ |
|
872 | 872 |
total_elapsed = time.time() - timestamp_start |
873 | 873 |
speed_fmt = formatSize(total_size/total_elapsed, human_readable = True, floating_point = True) |
874 | 874 |
|
... | ... |
@@ -883,22 +883,25 @@ def cmd_sync_remote2local(args): |
883 | 883 |
if cfg.delete_removed and cfg.delete_after: |
884 | 884 |
_do_deletes(local_list) |
885 | 885 |
|
886 |
-def local_hardlink(copy_pairs, destination_base): |
|
887 |
- failed_hardlink_list = SortedDict() |
|
886 |
+def local_copy(copy_pairs, destination_base): |
|
887 |
+ # Do NOT hardlink local files by default, that'd be silly |
|
888 |
+ # For instance all empty files would become hardlinked together! |
|
889 |
+ |
|
890 |
+ failed_copy_list = SortedDict() |
|
888 | 891 |
for (src_obj, dst1, relative_file) in copy_pairs: |
889 | 892 |
src_file = os.path.join(destination_base, dst1) |
890 | 893 |
dst_file = os.path.join(destination_base, relative_file) |
894 |
+ dst_dir = os.path.dirname(dst_file) |
|
891 | 895 |
try: |
892 |
- os.link(src_file, dst_file) |
|
893 |
- debug(u"Hardlinking %s to %s" % (src_file, dst_file)) |
|
894 |
- except (IOError, OSError): |
|
895 |
- try: |
|
896 |
- shutil.copy2(src_file, dst_file) |
|
897 |
- debug(u"Hardlinking unavailable, copying %s to %s" % (src_file, dst_file)) |
|
898 |
- except IOError, e: |
|
899 |
- warning(u'Unable to hardlink or copy files %s -> %s: %s' % (src_file, dst_file, e)) |
|
900 |
- failed_hardlink_list[relative_file] = src_obj |
|
901 |
- return failed_hardlink_list |
|
896 |
+ if not os.path.isdir(dst_dir): |
|
897 |
+ debug("MKDIR %s" % dst_dir) |
|
898 |
+ os.makedirs(dst_dir) |
|
899 |
+ debug(u"Copying %s to %s" % (src_file, dst_file)) |
|
900 |
+ shutil.copy2(src_file, dst_file) |
|
901 |
+ except (IOError, OSError), e: |
|
902 |
+ warning(u'Unable to hardlink or copy files %s -> %s: %s' % (src_file, dst_file, e)) |
|
903 |
+ failed_copy_list[relative_file] = src_obj |
|
904 |
+ return failed_copy_list |
|
902 | 905 |
|
903 | 906 |
def remote_copy(s3, copy_pairs, destination_base): |
904 | 907 |
saved_bytes = 0 |