summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2020-09-24 16:22:28 +0200
committerJürg Billeter <j@bitron.ch>2020-09-28 14:30:39 +0200
commitcecf8489e803d9bc847dc3845bff1591575db3e1 (patch)
treebb2d3059007148bb37c446b426e41426855bb4b4
parent0d35e6ce6324b57f02c1254c0ad3339f4973b666 (diff)
downloadbuildstream-cecf8489e803d9bc847dc3845bff1591575db3e1.tar.gz
_artifactcache.py: link_key(): Update reference if it exists already
We want the weak reference to point to the most recent artifact with the same weak cache key, not the oldest.
-rw-r--r--src/buildstream/_artifactcache.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/buildstream/_artifactcache.py b/src/buildstream/_artifactcache.py
index 2a5f5faa6..3cd34070d 100644
--- a/src/buildstream/_artifactcache.py
+++ b/src/buildstream/_artifactcache.py
@@ -294,8 +294,11 @@ class ArtifactCache(AssetCache):
oldref = element.get_artifact_name(oldkey)
newref = element.get_artifact_name(newkey)
- if not os.path.exists(os.path.join(self._basedir, newref)):
- os.link(os.path.join(self._basedir, oldref), os.path.join(self._basedir, newref))
+ if oldref == newref:
+ # The two refs are identical, nothing to do
+ return
+
+ utils.safe_link(os.path.join(self._basedir, oldref), os.path.join(self._basedir, newref))
# fetch_missing_blobs():
#