Browse code

Merge remote-tracking branch 'reed-sandberg/master' into merge

Matt Domsch authored on 2013/11/26 09:41:30
Showing 1 changed files
... ...
@@ -797,6 +797,7 @@ def cmd_sync_remote2local(args):
797 797
 
798 798
     info(u"Summary: %d remote files to download, %d local files to delete, %d local files to hardlink" % (remote_count + update_count, local_count, copy_pairs_count))
799 799
 
800
+    empty_fname_re = re.compile(r'\A\s*\Z')
800 801
     def _set_local_filename(remote_list, destination_base):
801 802
         if len(remote_list) == 0:
802 803
             return
... ...
@@ -809,7 +810,12 @@ def cmd_sync_remote2local(args):
809 809
             if destination_base[-1] != os.path.sep:
810 810
                 destination_base += os.path.sep
811 811
             for key in remote_list:
812
-                local_filename = destination_base + key
812
+                local_basename = key
813
+                if empty_fname_re.match(key):
814
+                    # Objects may exist on S3 with empty names (''), which don't map so well to common filesystems.
815
+                    local_basename = '__AWS-EMPTY-OBJECT-NAME__'
816
+                    warning(u"Empty object name on S3 found, saving locally as %s" % (local_basename))
817
+                local_filename = destination_base + local_basename
813 818
                 if os.path.sep != "/":
814 819
                     local_filename = os.path.sep.join(local_filename.split("/"))
815 820
                 remote_list[key]['local_filename'] = deunicodise(local_filename)