Binary caching: fix buildcache list (multiple invocations) (#19848)
When invoking "buildcache list" multiple times, the command was reporting no specs in the cache the second time around. The presence of an up-to-date index was causing the internal representation to be left un-initialized.
This commit is contained in:
parent
15fbbdea7d
commit
9d5f4f9c6f
@ -300,14 +300,11 @@ def update(self):
|
|||||||
cached_index_path = cache_entry['index_path']
|
cached_index_path = cache_entry['index_path']
|
||||||
if cached_mirror_url in configured_mirror_urls:
|
if cached_mirror_url in configured_mirror_urls:
|
||||||
# May need to fetch the index and update the local caches
|
# May need to fetch the index and update the local caches
|
||||||
needs_regen = self.fetch_and_cache_index(
|
needs_regen = self._fetch_and_cache_index(
|
||||||
cached_mirror_url, expect_hash=cached_index_hash)
|
cached_mirror_url, expect_hash=cached_index_hash)
|
||||||
# In this block, the need to regenerate implies a need to
|
# The need to regenerate implies a need to clear as well.
|
||||||
# clear as well. This is the first place we set these to
|
spec_cache_clear_needed |= needs_regen
|
||||||
# non-default values, so setting them False is fine. After
|
spec_cache_regenerate_needed |= needs_regen
|
||||||
# this, we should never set False again, only True.
|
|
||||||
spec_cache_clear_needed = needs_regen
|
|
||||||
spec_cache_regenerate_needed = needs_regen
|
|
||||||
else:
|
else:
|
||||||
# No longer have this mirror, cached index should be removed
|
# No longer have this mirror, cached index should be removed
|
||||||
items_to_remove.append({
|
items_to_remove.append({
|
||||||
@ -331,11 +328,9 @@ def update(self):
|
|||||||
for mirror_url in configured_mirror_urls:
|
for mirror_url in configured_mirror_urls:
|
||||||
if mirror_url not in self._local_index_cache:
|
if mirror_url not in self._local_index_cache:
|
||||||
# Need to fetch the index and update the local caches
|
# Need to fetch the index and update the local caches
|
||||||
needs_regen = self.fetch_and_cache_index(mirror_url)
|
needs_regen = self._fetch_and_cache_index(mirror_url)
|
||||||
# Generally speaking, a new mirror wouldn't imply the need to
|
# Generally speaking, a new mirror wouldn't imply the need to
|
||||||
# clear the spec cache, but don't touch it, which lets the
|
# clear the spec cache, so leave it as is.
|
||||||
# previous decisions stand. Also, only change the need to
|
|
||||||
# regenerate possibly from False to True.
|
|
||||||
if needs_regen:
|
if needs_regen:
|
||||||
spec_cache_regenerate_needed = True
|
spec_cache_regenerate_needed = True
|
||||||
|
|
||||||
@ -344,7 +339,7 @@ def update(self):
|
|||||||
if spec_cache_regenerate_needed:
|
if spec_cache_regenerate_needed:
|
||||||
self.regenerate_spec_cache(clear_existing=spec_cache_clear_needed)
|
self.regenerate_spec_cache(clear_existing=spec_cache_clear_needed)
|
||||||
|
|
||||||
def fetch_and_cache_index(self, mirror_url, expect_hash=None):
|
def _fetch_and_cache_index(self, mirror_url, expect_hash=None):
|
||||||
""" Fetch a buildcache index file from a remote mirror and cache it.
|
""" Fetch a buildcache index file from a remote mirror and cache it.
|
||||||
|
|
||||||
If we already have a cached index from this mirror, then we first
|
If we already have a cached index from this mirror, then we first
|
||||||
|
Loading…
Reference in New Issue
Block a user