summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan van Berkom <tristan@codethink.co.uk>2020-12-11 18:56:03 +0900
committerTristan van Berkom <tristan@codethink.co.uk>2020-12-11 18:56:03 +0900
commit0f59c939884d618a6ef743aa2e57eb50016f0abf (patch)
treeac7d454e23093c1f8a911649bdcf8cbc7900c197
parent2e4800f494794cd7d88017661b42cc85ea54e7fc (diff)
downloadbuildstream-0f59c939884d618a6ef743aa2e57eb50016f0abf.tar.gz
_assetcache.py: Allow explicit re-initialization of remotes.
This is merely because the structure of remotes is heavily bound to loaded projects, and in some cases we need to download some artifacts before some ArtifactProjects can exist and then later pull elements related to those newly created ArtifactProject instances. This is rather a silly workaround, instead the data structure of remotes should be reorganized, which is a larger task and probably appropriate to examine when re-examining remote service configuration surfaces.
-rw-r--r--src/buildstream/_assetcache.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/buildstream/_assetcache.py b/src/buildstream/_assetcache.py
index a0b502f2b..3993ca834 100644
--- a/src/buildstream/_assetcache.py
+++ b/src/buildstream/_assetcache.py
@@ -366,11 +366,18 @@ class AssetCache:
# Args:
# use_config (bool): Whether to use project configuration
# remote_url (str): Remote cache URL
+ # reinitialize (bool): Whether to re-initialize the remotes a second time
#
# This requires that all of the projects which are to be processed in the session
# have already been loaded and are observable in the Context.
#
- def setup_remotes(self, *, use_config=False, remote_url=None):
+ def setup_remotes(self, *, use_config=False, remote_url=None, reinitialize=False):
+
+ # In some edge cases we need to reinitialize
+ if reinitialize:
+ self._storage_remotes = {}
+ self._index_remotes = {}
+ self._remotes_setup = False
# Ensure we do not double-initialise since this can be expensive
if self._remotes_setup: