Fix: Avoid race condition creating directory

This happened on the buildbot with multithreaded tests.
This commit is contained in:
Brecht Van Lommel
2024-02-07 15:45:49 +01:00
parent e4aa83d2ee
commit 78760f0866
3 changed files with 3 additions and 8 deletions

View File

@ -106,10 +106,7 @@ def getPresetpaths():
"""Return paths for both local and user preset folders"""
userDir = os.path.join(bpy.utils.script_path_user(), 'presets', 'operator', 'add_curve_sapling')
if os.path.isdir(userDir):
pass
else:
os.makedirs(userDir)
os.makedirs(userDir, exist_ok=True)
script_file = os.path.realpath(__file__)
directory = os.path.dirname(script_file)

View File

@ -35,8 +35,7 @@ class IO_Utils():
# stored_views preset folder doesn't exist, so create it
paths = [os.path.join(bpy.utils.user_resource('SCRIPTS'), "presets",
"stored_views")]
if not os.path.exists(paths[0]):
os.makedirs(paths[0])
os.makedirs(paths[0], exist_ok=True)
return(paths)

View File

@ -875,8 +875,7 @@ class IO_Utils():
# stored_views preset folder doesn't exist, so create it
paths = [os.path.join(bpy.utils.user_resource('SCRIPTS'), "presets",
"stored_views")]
if not os.path.exists(paths[0]):
os.makedirs(paths[0])
os.makedirs(paths[0], exist_ok=True)
return(paths)