Browse code

be verbose when both hardlinking and copying of local files fails

We will need to actually do the download then.

Matt Domsch authored on 2012/12/08 13:50:25
Showing 1 changed files
... ...
@@ -857,7 +857,8 @@ def cmd_sync_remote2local(args):
857 857
     seq = 0
858 858
     seq, total_size = _download(remote_list, seq, remote_count + update_count, total_size, dir_cache)
859 859
     seq, total_size = _download(update_list, seq, remote_count + update_count, total_size, dir_cache)
860
-    local_hardlink(copy_pairs, destination_base)
860
+    failed_pairs = local_hardlink(copy_pairs, destination_base)
861
+    # fixme: do something about failed pairs - we couldn't hardlink or copy them, need to retrieve them
861 862
     
862 863
     total_elapsed = time.time() - timestamp_start
863 864
     speed_fmt = formatSize(total_size/total_elapsed, human_readable = True, floating_point = True)
... ...
@@ -874,13 +875,19 @@ def cmd_sync_remote2local(args):
874 874
         _do_deletes(local_list)
875 875
 
876 876
 def local_hardlink(copy_pairs, destination_base):
877
+    failed_pairs = []
877 878
     for (dst1, dst2) in copy_pairs:
878 879
         try:
879 880
             os.link(destination_base + dst1, destination_base + dst2)
880 881
             debug(u"Hardlinking %s to %s" % (destination_base + dst1, destination_base + dst2))
881
-        except:
882
-            shutil.copy2(destination_base + dst1, destination_base + dst2)
883
-            debug(u"Hardlinking unavailable, copying %s to %s" % (destination_base + dst1, destination_base + dst2))
882
+        except (IOError, OSError):
883
+            try:
884
+                shutil.copy2(destination_base + dst1, destination_base + dst2)
885
+                debug(u"Hardlinking unavailable, copying %s to %s" % (destination_base + dst1, destination_base + dst2))
886
+            except IOError, e:
887
+                error(u'Unable to hardlink or copy files %s -> %s: %s' % (destination_base+dst1, destination_base+dst2, e))
888
+                failed_pairs.append((dst1, dst2))
889
+    return failed_pairs
884 890
 
885 891
 def remote_copy(s3, copy_pairs, destination_base):
886 892
     saved_bytes = 0