diff options
author | Daniel Silverstone <daniel.silverstone@codethink.co.uk> | 2018-09-18 09:36:57 +0100 |
---|---|---|
committer | Daniel Silverstone <daniel.silverstone@codethink.co.uk> | 2018-09-18 09:41:32 +0100 |
commit | 7b117e407ed353529c4ec5b890cba44c987e23a4 (patch) | |
tree | 3ad20332b65c2122775aa7634d08f147d8e37bbc | |
parent | f2ae46f8e59212f78336cf3e4adfe4ac40095110 (diff) | |
download | buildstream-7b117e407ed353529c4ec5b890cba44c987e23a4.tar.gz |
_artifactcache/artifactcache.py: Ensure no double-setup of remotes
Since ArtifactCache.setup_remotes() can be expensive and should only
happen once, this commit will assert() if it is called a second time
on an artifact cache instance.
Signed-off-by: Daniel Silverstone <daniel.silverstone@codethink.co.uk>
-rw-r--r-- | buildstream/_artifactcache/artifactcache.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py index eb7759d83..b5c27a165 100644 --- a/buildstream/_artifactcache/artifactcache.py +++ b/buildstream/_artifactcache/artifactcache.py @@ -91,6 +91,7 @@ class ArtifactCache(): self._cache_size = None # The current cache size, sometimes it's an estimate self._cache_quota = None # The cache quota self._cache_lower_threshold = None # The target cache size for a cleanup + self._remotes_setup = False # Check to prevent double-setup of remotes os.makedirs(self.extractdir, exist_ok=True) os.makedirs(self.tmpdir, exist_ok=True) @@ -143,6 +144,10 @@ class ArtifactCache(): # def setup_remotes(self, *, use_config=False, remote_url=None): + # Ensure we do not double-initialise since this can be expensive + assert(not self._remotes_setup) + self._remotes_setup = True + # Initialize remote artifact caches. We allow the commandline to override # the user config in some cases (for example `bst push --remote=...`). has_remote_caches = False |