Fix spack locking on some NFS systems (#32426)

Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
This commit is contained in:
Seth R. Johnson 2022-09-06 12:50:59 -04:00 committed by GitHub
parent d7d59a24d1
commit c7292aa4b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -386,8 +386,12 @@ def _ensure_parent_directory(self):
try:
os.makedirs(parent)
except OSError as e:
# makedirs can fail when diretory already exists.
if not (e.errno == errno.EEXIST and os.path.isdir(parent) or e.errno == errno.EISDIR):
# os.makedirs can fail in a number of ways when the directory already exists.
# 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
return parent