because the local file may be unreadable.
Matt Domsch authored on 2012/12/08 13:00:21... | ... |
@@ -193,8 +193,11 @@ def fetch_local_list(args, recursive = None): |
193 | 193 |
if 'md5' in cfg.sync_checks: |
194 | 194 |
md5 = cache.md5(sr.st_dev, sr.st_ino, sr.st_mtime, sr.st_size) |
195 | 195 |
if md5 is None: |
196 |
- md5 = loc_list.get_md5(relative_file) # this does the file I/O |
|
197 |
- cache.add(sr.st_dev, sr.st_ino, sr.st_mtime, sr.st_size, md5) |
|
196 |
+ try: |
|
197 |
+ md5 = loc_list.get_md5(relative_file) # this does the file I/O |
|
198 |
+ except IOError: |
|
199 |
+ continue |
|
200 |
+ cache.add(sr.st_dev, sr.st_ino, sr.st_mtime, sr.st_size, md5) |
|
198 | 201 |
loc_list.record_hardlink(relative_file, sr.st_dev, sr.st_ino, md5) |
199 | 202 |
return loc_list, single_file |
200 | 203 |
|
... | ... |
@@ -460,7 +463,10 @@ def compare_filelists(src_list, dst_list, src_remote, dst_remote, delay_updates |
460 | 460 |
|
461 | 461 |
else: |
462 | 462 |
# look for matching file in src |
463 |
- md5 = src_list.get_md5(relative_file) |
|
463 |
+ try: |
|
464 |
+ md5 = src_list.get_md5(relative_file) |
|
465 |
+ except IOError: |
|
466 |
+ md5 = None |
|
464 | 467 |
if md5 is not None and dst_list.by_md5.has_key(md5): |
465 | 468 |
# Found one, we want to copy |
466 | 469 |
dst1 = list(dst_list.by_md5[md5])[0] |
... | ... |
@@ -479,7 +485,10 @@ def compare_filelists(src_list, dst_list, src_remote, dst_remote, delay_updates |
479 | 479 |
else: |
480 | 480 |
# dst doesn't have this file |
481 | 481 |
# look for matching file elsewhere in dst |
482 |
- md5 = src_list.get_md5(relative_file) |
|
482 |
+ try: |
|
483 |
+ md5 = src_list.get_md5(relative_file) |
|
484 |
+ except IOError: |
|
485 |
+ md5 = None |
|
483 | 486 |
dst1 = dst_list.find_md5_one(md5) |
484 | 487 |
if dst1 is not None: |
485 | 488 |
# Found one, we want to copy |
... | ... |
@@ -918,7 +918,10 @@ def cmd_sync_local2remote(args): |
918 | 918 |
val = local_list[src].get('gid') |
919 | 919 |
warning(u"%s: Owner groupname not known. Storing GID=%d instead." % (src, val)) |
920 | 920 |
elif attr == 'md5': |
921 |
- val = local_list.get_md5(src) |
|
921 |
+ try: |
|
922 |
+ val = local_list.get_md5(src) |
|
923 |
+ except IOError: |
|
924 |
+ val = None |
|
922 | 925 |
else: |
923 | 926 |
val = getattr(local_list[src]['sr'], 'st_' + attr) |
924 | 927 |
attrs[attr] = val |