Skip to content

Commit fc29720

Browse files
authored
Fix makedirs (#320)
* fix for makedirs race condition * changelog
1 parent baf0c78 commit fc29720

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1010
### Fixed
1111

1212
- Restored fs.path import
13+
- Fixed potential race condition in makedirs. Fixes [#310](https://github.com/PyFilesystem/pyfilesystem2/issues/310)
1314

1415
### Changed
1516

fs/base.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,10 +1067,13 @@ def makedirs(
10671067
with self._lock:
10681068
dir_paths = tools.get_intermediate_dirs(self, path)
10691069
for dir_path in dir_paths:
1070-
self.makedir(dir_path, permissions=permissions)
1071-
1070+
try:
1071+
self.makedir(dir_path, permissions=permissions)
1072+
except errors.DirectoryExists:
1073+
if not recreate:
1074+
raise
10721075
try:
1073-
self.makedir(path)
1076+
self.makedir(path, permissions=permissions)
10741077
except errors.DirectoryExists:
10751078
if not recreate:
10761079
raise

0 commit comments

Comments
 (0)