17779: Fix invalid manifest throwing IOError instead of SyntaxError.
[arvados.git] / sdk / python / arvados / collection.py
index 1744cc7be6db20aaaf11ac0917a7db447c8637b4..d03265ca44b1b6e886e57d455dadcb7a613d0b6e 100644 (file)
@@ -1790,7 +1790,13 @@ class Collection(RichCollectionBase):
                             self.find_or_create(os.path.join(stream_name, name[:-2]), COLLECTION)
                     else:
                         filepath = os.path.join(stream_name, name)
-                        afile = self.find_or_create(filepath, FILE)
+                        try:
+                            afile = self.find_or_create(filepath, FILE)
+                        except IOError as e:
+                            if e.errno == errno.ENOTDIR:
+                                raise errors.SyntaxError("Dir part of %s conflicts with file of the same name.", filepath) from None
+                            else:
+                                raise e from None
                         if isinstance(afile, ArvadosFile):
                             afile.add_segment(blocks, pos, size)
                         else: