Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

wrap get_md5() with try/except IOError

because the local file may be unreadable.
  • Loading branch information...
commit 772691bde966cacd3d20979808e92e40d642c268 1 parent 9525d62
@mdomsch authored committed
Showing with 18 additions and 5 deletions.
  1. +13 −4 S3/FileLists.py
  2. +1 −0  S3/SortedDict.py
  3. +4 −1 s3cmd
View
17 S3/FileLists.py
@@ -193,8 +193,11 @@ def _get_filelist_local(loc_list, local_uri, cache):
if 'md5' in cfg.sync_checks:
md5 = cache.md5(sr.st_dev, sr.st_ino, sr.st_mtime, sr.st_size)
if md5 is None:
- md5 = loc_list.get_md5(relative_file) # this does the file I/O
- cache.add(sr.st_dev, sr.st_ino, sr.st_mtime, sr.st_size, md5)
+ try:
+ md5 = loc_list.get_md5(relative_file) # this does the file I/O
+ except IOError:
+ continue
+ cache.add(sr.st_dev, sr.st_ino, sr.st_mtime, sr.st_size, md5)
loc_list.record_hardlink(relative_file, sr.st_dev, sr.st_ino, md5)
return loc_list, single_file
@@ -460,7 +463,10 @@ def _compare(src_list, dst_lst, src_remote, dst_remote, file):
else:
# look for matching file in src
- md5 = src_list.get_md5(relative_file)
+ try:
+ md5 = src_list.get_md5(relative_file)
+ except IOError:
+ md5 = None
if md5 is not None and dst_list.by_md5.has_key(md5):
# Found one, we want to copy
dst1 = list(dst_list.by_md5[md5])[0]
@@ -479,7 +485,10 @@ def _compare(src_list, dst_lst, src_remote, dst_remote, file):
else:
# dst doesn't have this file
# look for matching file elsewhere in dst
- md5 = src_list.get_md5(relative_file)
+ try:
+ md5 = src_list.get_md5(relative_file)
+ except IOError:
+ md5 = None
dst1 = dst_list.find_md5_one(md5)
if dst1 is not None:
# Found one, we want to copy
View
1  S3/SortedDict.py
@@ -61,6 +61,7 @@ def find_md5_one(self, md5):
return None
def get_md5(self, relative_file):
+ """returns md5 if it can, or raises IOError if file is unreadable"""
md5 = None
if 'md5' in self[relative_file]:
return self[relative_file]['md5']
View
5 s3cmd
@@ -918,7 +918,10 @@ def cmd_sync_local2remote(args):
val = local_list[src].get('gid')
warning(u"%s: Owner groupname not known. Storing GID=%d instead." % (src, val))
elif attr == 'md5':
- val = local_list.get_md5(src)
+ try:
+ val = local_list.get_md5(src)
+ except IOError:
+ val = None
else:
val = getattr(local_list[src]['sr'], 'st_' + attr)
attrs[attr] = val
Please sign in to comment.
Something went wrong with that request. Please try again.