Skip to content

Commit

Permalink
Merge pull request #91 from EliahKagan/toctou
Browse files Browse the repository at this point in the history
Fix mkdir race condition in LooseObjectDB.store
  • Loading branch information
Byron authored Sep 11, 2023
2 parents d22ac20 + 60f7f94 commit 295a55b
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions gitdb/db/loose.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
ObjectDBW
)


from gitdb.exc import (
BadObject,
AmbiguousObjectName
Expand All @@ -33,10 +32,8 @@
bin_to_hex,
exists,
chmod,
isdir,
isfile,
remove,
mkdir,
rename,
dirname,
basename,
Expand Down Expand Up @@ -222,8 +219,7 @@ def store(self, istream):
if tmp_path:
obj_path = self.db_path(self.object_path(hexsha))
obj_dir = dirname(obj_path)
if not isdir(obj_dir):
mkdir(obj_dir)
os.makedirs(obj_dir, exist_ok=True)
# END handle destination directory
# rename onto existing doesn't work on NTFS
if isfile(obj_path):
Expand Down

0 comments on commit 295a55b

Please sign in to comment.