Skip to content

Commit

Permalink
Merge pull request #715 from czalidis/fix-download-checkmd5
Browse files Browse the repository at this point in the history
Fix potential race condition in 'download_checkmd5.py'
  • Loading branch information
dirk-thomas committed Feb 4, 2015
2 parents 1071c19 + a9ad503 commit 6d9e3eb
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 6d9e3eb

Please sign in to comment.