Skip to content

Commit

Permalink
Merge pull request #21409 from jquast/makedirs-race-condition
Browse files Browse the repository at this point in the history
Gracefully handle race condition of 'makedirs'
  • Loading branch information
thatch45 committed Mar 9, 2015
2 parents 7ed498d + 5141052 commit ab4d5b7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion salt/utils/verify.py
Expand Up @@ -11,6 +11,7 @@
import re
import sys
import stat
import errno
import socket
import logging

Expand Down Expand Up @@ -162,8 +163,11 @@ def verify_files(files, user):
for fn_ in files:
dirname = os.path.dirname(fn_)
try:
if not os.path.isdir(dirname):
try:
os.makedirs(dirname)
except OSError as err:
if err.errno != errno.EEXIST:
raise
if not os.path.isfile(fn_):
with salt.utils.fopen(fn_, 'w+') as fp_:
fp_.write('')
Expand Down

0 comments on commit ab4d5b7

Please sign in to comment.