Browse code

Merge pull request #253 from mdomsch/bug/unicode-stat

encode filenames to system encoding before calling shutils.copy2()

Matt Domsch authored on 2013/12/06 06:41:54
Showing 1 changed files
... ...
@@ -989,7 +989,7 @@ def cmd_sync_remote2local(args):
989 989
 def local_copy(copy_pairs, destination_base):
990 990
     # Do NOT hardlink local files by default, that'd be silly
991 991
     # For instance all empty files would become hardlinked together!
992
-
992
+    encoding = sys.getfilesystemencoding()
993 993
     failed_copy_list = FileDict()
994 994
     for (src_obj, dst1, relative_file) in copy_pairs:
995 995
         src_file = os.path.join(destination_base, dst1)
... ...
@@ -1000,7 +1000,7 @@ def local_copy(copy_pairs, destination_base):
1000 1000
                 debug("MKDIR %s" % dst_dir)
1001 1001
                 os.makedirs(dst_dir)
1002 1002
             debug(u"Copying %s to %s" % (src_file, dst_file))
1003
-            shutil.copy2(src_file, dst_file)
1003
+            shutil.copy2(src_file.encode(encoding), dst_file.encode(encoding))
1004 1004
         except (IOError, OSError), e:
1005 1005
             warning(u'Unable to hardlink or copy files %s -> %s: %s' % (src_file, dst_file, e))
1006 1006
             failed_copy_list[relative_file] = src_obj