Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 295a55b

Browse files
authored
Merge pull request #91 from EliahKagan/toctou
Fix mkdir race condition in LooseObjectDB.store
2 parents d22ac20 + 60f7f94 commit 295a55b

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

‎gitdb/db/loose.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
ObjectDBW
99
)
1010

11-
1211
from gitdb.exc import (
1312
BadObject,
1413
AmbiguousObjectName
@@ -33,10 +32,8 @@
3332
bin_to_hex,
3433
exists,
3534
chmod,
36-
isdir,
3735
isfile,
3836
remove,
39-
mkdir,
4037
rename,
4138
dirname,
4239
basename,
@@ -222,8 +219,7 @@ def store(self, istream):
222219
if tmp_path:
223220
obj_path = self.db_path(self.object_path(hexsha))
224221
obj_dir = dirname(obj_path)
225-
if not isdir(obj_dir):
226-
mkdir(obj_dir)
222+
os.makedirs(obj_dir, exist_ok=True)
227223
# END handle destination directory
228224
# rename onto existing doesn't work on NTFS
229225
if isfile(obj_path):

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /