diff options
author | Jürg Billeter <j@bitron.ch> | 2020-09-24 16:22:28 +0200 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2020-09-24 16:51:06 +0200 |
commit | 3d70d4b9a8b5eba067305bd26f5f8d6cf2ffc5ac (patch) | |
tree | c609710e5ecd3e3863b77758ba13ebc21835124a | |
parent | 115054e7e372116ca36636b63639d2401e0fefe0 (diff) | |
download | buildstream-3d70d4b9a8b5eba067305bd26f5f8d6cf2ffc5ac.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.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/buildstream/_artifactcache.py b/src/buildstream/_artifactcache.py index 2a5f5faa6..df0385f98 100644 --- a/src/buildstream/_artifactcache.py +++ b/src/buildstream/_artifactcache.py @@ -291,11 +291,14 @@ class ArtifactCache(AssetCache): # newkey (str): A new cache key for the artifact # def link_key(self, element, oldkey, newkey): + if oldkey == newkey: + # The two keys are identical, nothing to do + return + 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)) + utils.safe_link(os.path.join(self._basedir, oldref), os.path.join(self._basedir, newref)) # fetch_missing_blobs(): # |