14345: Accept "." placeholder: create parent dir, but no fake file.
authorTom Clegg <tclegg@veritasgenetics.com>
Tue, 6 Nov 2018 14:54:10 +0000 (09:54 -0500)
committerTom Clegg <tclegg@veritasgenetics.com>
Thu, 8 Nov 2018 16:21:34 +0000 (11:21 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

sdk/python/arvados/collection.py

index f4502b7e668113a6eed7809f5e6552c2a298f055..6b33ea3030fa48d7f492d8f6df41abf896356e1b 100644 (file)
@@ -1717,12 +1717,17 @@ class Collection(RichCollectionBase):
                     pos = int(file_segment.group(1))
                     size = int(file_segment.group(2))
                     name = self._unescape_manifest_path(file_segment.group(3))
-                    filepath = os.path.join(stream_name, name)
-                    afile = self.find_or_create(filepath, FILE)
-                    if isinstance(afile, ArvadosFile):
-                        afile.add_segment(blocks, pos, size)
+                    if name.split('/')[-1] == '.':
+                        # placeholder for persisting an empty directory, not a real file
+                        if len(name) > 2:
+                            self.find_or_create(os.path.join(stream_name, name[:-2]), COLLECTION)
                     else:
-                        raise errors.SyntaxError("File %s conflicts with stream of the same name.", filepath)
+                        filepath = os.path.join(stream_name, name)
+                        afile = self.find_or_create(filepath, FILE)
+                        if isinstance(afile, ArvadosFile):
+                            afile.add_segment(blocks, pos, size)
+                        else:
+                            raise errors.SyntaxError("File %s conflicts with stream of the same name.", filepath)
                 else:
                     # error!
                     raise errors.SyntaxError("Invalid manifest format, expected file segment but did not match format: '%s'" % tok)