Skip to content

Commit

Permalink
Fix potential race condition in 'download_checkmd5.py'
Browse files Browse the repository at this point in the history
  • Loading branch information
czalidis committed Feb 4, 2015
1 parent 1071c19 commit a9ad503
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cmake/test/download_checkmd5.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python

from __future__ import print_function
import errno
import os
import sys
try:
Expand Down Expand Up @@ -87,8 +88,12 @@ def download_md5(uri, dest):
"""
# Create intermediate directories as necessary, #2970
dirname = os.path.dirname(dest)
if len(dirname) and not os.path.exists(dirname):
os.makedirs(dirname)
if len(dirname):
try:
os.makedirs(dirname)
except OSError as e:
if e.errno != errno.EEXIST:
raise

sys.stdout.write('Downloading %s to %s...' % (uri, dest))
sys.stdout.flush()
Expand Down

0 comments on commit a9ad503

Please sign in to comment.