@@ -944,8 +944,20 @@ def mkdirhier(directory):
try:
os.makedirs(directory)
except OSError as e:
- if e.errno != errno.EEXIST or not os.path.isdir(directory):
+ if e.errno != errno.EEXIST:
raise e
+ if os.path.isdir(directory):
+ return
+ # We can end up here if there is a race between two mkdirs on an NFS mount,
+ # which happens more often with sstate that you'd think. The server returns
+ # EEXIST but the local attribute cache is out of date. It can be refreshed with
+ # an opendir call, so try that (via listdir) and check the directory again
+ # before we really fail.
+ os.listdir(os.path.dirname(directory))
+ if os.path.isdir(directory):
+ return
+ bb.warn("mkdir: %s is not a directory?")
+ raise e
def movefile(src, dest, newmtime = None, sstat = None):
"""Moves a file from ``src`` to ``dest``, preserving all permissions and