If remote doesn't have any copies of the file, we transfer one
instance first, then copy thereafter. But we were dereferencing the
destination list improperly in this case, causing a crash. This patch
fixes the crash cleanly.
... | ... |
@@ -428,7 +428,7 @@ def compare_filelists(src_list, dst_list, src_remote, dst_remote, delay_updates |
428 | 428 |
# Found one, we want to copy |
429 | 429 |
dst1 = list(dst_list.by_md5[md5])[0] |
430 | 430 |
debug(u"REMOTE COPY src: %s -> %s" % (dst1, relative_file)) |
431 |
- copy_pairs.append((dst_list[dst1], relative_file)) |
|
431 |
+ copy_pairs.append((dst1, relative_file)) |
|
432 | 432 |
del(src_list[relative_file]) |
433 | 433 |
del(dst_list[relative_file]) |
434 | 434 |
else: |
... | ... |
@@ -448,7 +448,8 @@ def compare_filelists(src_list, dst_list, src_remote, dst_remote, delay_updates |
448 | 448 |
if dst1 is not None: |
449 | 449 |
# Found one, we want to copy |
450 | 450 |
debug(u"REMOTE COPY dst: %s -> %s" % (dst1, relative_file)) |
451 |
- copy_pairs.append((dst_list[dst1], relative_file)) |
|
451 |
+ # FIXME this blows up when dst1 is not in dst_list, because we added it below in record_md5 but it's not really in dst_list. |
|
452 |
+ copy_pairs.append((dst1, relative_file)) |
|
452 | 453 |
del(src_list[relative_file]) |
453 | 454 |
else: |
454 | 455 |
# we don't have this file, and we don't have a copy of this file elsewhere. Get it. |
... | ... |
@@ -845,11 +845,13 @@ def remote_copy(s3, remote_list, copy_pairs, destination_base): |
845 | 845 |
saved_bytes = 0 |
846 | 846 |
for (dst1, dst2) in copy_pairs: |
847 | 847 |
debug(u"Remote Copying from %s to %s" % (dst1, dst2)) |
848 |
- dst_uri = S3Uri(destination_base + dst2) |
|
848 |
+ dst1_uri = S3Uri(destination_base + dst1) |
|
849 |
+ dst2_uri = S3Uri(destination_base + dst2) |
|
849 | 850 |
extra_headers = copy(cfg.extra_headers) |
850 | 851 |
try: |
851 |
- s3.object_copy(S3Uri(dst1['object_uri_str']), dst_uri, extra_headers) |
|
852 |
- saved_bytes = saved_bytes + dst1['size'] |
|
852 |
+ s3.object_copy(dst1_uri, dst2_uri, extra_headers) |
|
853 |
+ info = s3.object_info(dst2_uri) |
|
854 |
+ saved_bytes = saved_bytes + int(info['headers']['content-length']) |
|
853 | 855 |
except: |
854 | 856 |
raise |
855 | 857 |
return (len(copy_pairs), saved_bytes) |