summaryrefslogtreecommitdiff
path: root/buildstream/_artifactcache.py
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-04-13 18:49:26 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-04-13 19:01:32 +0900
commit296f41a6cb80d7c7a5bef5323495e78999721a82 (patch)
tree9f82167a320338de34a7f8351ff3ad7321be51f4 /buildstream/_artifactcache.py
parenta49d1aa4fda79cbffb8483638820109df7dcebb4 (diff)
downloadbuildstream-296f41a6cb80d7c7a5bef5323495e78999721a82.tar.gz
_artifactcache.py: Fixing concurrent artifact extractions
Catch both EEXIST and not ENOTEMPTY from os.rename(). Seems that low level rename() calls (see `man 2 rename`) document this call to report either EEXIST _or_ ENOTEMPTY (at the OS/libc's discretion) in the case that the destination directory exists and is not empty.
Diffstat (limited to 'buildstream/_artifactcache.py')
-rw-r--r--buildstream/_artifactcache.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/buildstream/_artifactcache.py b/buildstream/_artifactcache.py
index 191d821e8..7e89f6c86 100644
--- a/buildstream/_artifactcache.py
+++ b/buildstream/_artifactcache.py
@@ -111,13 +111,15 @@ class ArtifactCache():
try:
os.rename(checkoutdir, dest)
except OSError as e:
- if e.errno != os.errno.ENOTEMPTY:
+ # With rename, it's possible to get either ENOTEMPTY or EEXIST
+ # in the case that the destination path is a not empty directory.
+ #
+ # If rename fails with these errors, another process beat
+ # us to it so just ignore.
+ if e.errno not in [os.errno.ENOTEMPTY, os.errno.EEXIST]:
raise ArtifactError("Failed to extract artifact for ref '{}': {}"
.format(ref, e)) from e
- # If rename fails with ENOTEMPTY, another process beat
- # us to it. This is no issue.
-
return dest
# commit():