Skip to content

Commit

Permalink
Performance: Reduce call exists in makedirs (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghua authored Sep 19, 2024
1 parent acd4bd5 commit c2b7978
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tosfs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,10 @@ def makedirs(self, path: str, exist_ok: bool = False) -> None:
"""
path = self._strip_protocol(path).rstrip("/") + "/"
if exist_ok and self.exists(path):
path_exist = self.exists(path)
if exist_ok and path_exist:
return
if not exist_ok and self.exists(path):
if not exist_ok and path_exist:
raise FileExistsError(path)

self.mkdir(path, create_parents=True)
Expand Down

0 comments on commit c2b7978

Please sign in to comment.