Skip to content

Commit

Permalink
Performance: Reduce call exists in makedirs
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghua committed Sep 16, 2024
1 parent 91c6300 commit d8b0f3d
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 @@ -495,9 +495,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 d8b0f3d

Please sign in to comment.