Permalink
Browse files

be verbose when both hardlinking and copying of local files fails

We will need to actually do the download then.
  • Loading branch information...
1 parent 89d49c8 commit b2b081382fe4453385145be328a6007777300bc7 @mdomsch committed with Dec 8, 2012
Showing with 11 additions and 4 deletions.
  1. +11 −4 s3cmd
View
15 s3cmd
@@ -857,7 +857,8 @@ def cmd_sync_remote2local(args):
seq = 0
seq, total_size = _download(remote_list, seq, remote_count + update_count, total_size, dir_cache)
seq, total_size = _download(update_list, seq, remote_count + update_count, total_size, dir_cache)
- local_hardlink(copy_pairs, destination_base)
+ failed_pairs = local_hardlink(copy_pairs, destination_base)
+ # fixme: do something about failed pairs - we couldn't hardlink or copy them, need to retrieve them
total_elapsed = time.time() - timestamp_start
speed_fmt = formatSize(total_size/total_elapsed, human_readable = True, floating_point = True)
@@ -874,13 +875,19 @@ def cmd_sync_remote2local(args):
_do_deletes(local_list)
def local_hardlink(copy_pairs, destination_base):
+ failed_pairs = []
for (dst1, dst2) in copy_pairs:
try:
os.link(destination_base + dst1, destination_base + dst2)
debug(u"Hardlinking %s to %s" % (destination_base + dst1, destination_base + dst2))
- except:
- shutil.copy2(destination_base + dst1, destination_base + dst2)
- debug(u"Hardlinking unavailable, copying %s to %s" % (destination_base + dst1, destination_base + dst2))
+ except (IOError, OSError):
+ try:
+ shutil.copy2(destination_base + dst1, destination_base + dst2)
+ debug(u"Hardlinking unavailable, copying %s to %s" % (destination_base + dst1, destination_base + dst2))
+ except IOError, e:
+ error(u'Unable to hardlink or copy files %s -> %s: %s' % (destination_base+dst1, destination_base+dst2, e))
+ failed_pairs.append((dst1, dst2))
+ return failed_pairs
def remote_copy(s3, copy_pairs, destination_base):
saved_bytes = 0

0 comments on commit b2b0813

Please sign in to comment.