Browse code

Correct path generation in local_hardlink()

Instead of dir+file use os.path.join(dir,file). The former
leads to an incorrect result if 'dir' doesn't end with '/'

Michal Ludvig authored on 2013/02/18 19:44:37
Showing 1 changed files
... ...
@@ -886,15 +886,17 @@ def cmd_sync_remote2local(args):
886 886
 def local_hardlink(copy_pairs, destination_base):
887 887
     failed_hardlink_list = SortedDict()
888 888
     for (src_obj, dst1, relative_file) in copy_pairs:
889
+        src_file = os.path.join(destination_base, dst1)
890
+        dst_file = os.path.join(destination_base, relative_file)
889 891
         try:
890
-            os.link(destination_base + dst1, destination_base + relative_file)
891
-            debug(u"Hardlinking %s to %s" % (destination_base + dst1, destination_base + relative_file))
892
+            os.link(src_file, dst_file)
893
+            debug(u"Hardlinking %s to %s" % (src_file, dst_file))
892 894
         except (IOError, OSError):
893 895
             try:
894
-                shutil.copy2(destination_base + dst1, destination_base + relative_file)
895
-                debug(u"Hardlinking unavailable, copying %s to %s" % (destination_base + dst1, destination_base + relative_file))
896
+                shutil.copy2(src_file, dst_file)
897
+                debug(u"Hardlinking unavailable, copying %s to %s" % (src_file, dst_file))
896 898
             except IOError, e:
897
-                warning(u'Unable to hardlink or copy files %s -> %s: %s' % (destination_base + dst1, destination_base + relative_file, e))
899
+                warning(u'Unable to hardlink or copy files %s -> %s: %s' % (src_file, dst_file, e))
898 900
                 failed_hardlink_list[relative_file] = src_obj
899 901
     return failed_hardlink_list
900 902