Fix spack locking on some NFS systems (#32426)
Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
This commit is contained in:
parent
d7d59a24d1
commit
c7292aa4b6
@ -386,8 +386,12 @@ def _ensure_parent_directory(self):
|
|||||||
try:
|
try:
|
||||||
os.makedirs(parent)
|
os.makedirs(parent)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
# makedirs can fail when diretory already exists.
|
# os.makedirs can fail in a number of ways when the directory already exists.
|
||||||
if not (e.errno == errno.EEXIST and os.path.isdir(parent) or e.errno == errno.EISDIR):
|
# With EISDIR, we know it exists, and others like EEXIST, EACCES, and EROFS
|
||||||
|
# are fine if we ensure that the directory exists.
|
||||||
|
# Python 3 allows an exist_ok parameter and ignores any OSError as long as
|
||||||
|
# the directory exists.
|
||||||
|
if not (e.errno == errno.EISDIR or os.path.isdir(parent)):
|
||||||
raise
|
raise
|
||||||
return parent
|
return parent
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user