Extensions: simplify access to manifests when refreshing the remote

The internal API call to refresh remote data wasn't returning
the resulting data, making it inconvenient to refresh & access
remote meta-data from a single repository.
This commit is contained in:
Campbell Barton 2024-06-14 15:12:21 +10:00
parent 2dd339bff3
commit 04f310a19a
2 changed files with 9 additions and 21 deletions

@ -145,23 +145,10 @@ def repo_stats_calc_outdated_for_repo_directory(repo_directory):
if pkg_manifest_local is None: if pkg_manifest_local is None:
return 0 return 0
# pylint: disable-next=using-constant-test pkg_manifest_remote = repo_cache_store.refresh_remote_from_directory(
if False: directory=repo_directory,
# TODO: support this, currently creating this data involves a conversion which isn't free. error_fn=print,
# This can probably be done once and cached, but for now use another function that provides this. )
pkg_manifest_remote = repo_cache_store.refresh_remote_from_directory(
directory=repo_directory,
error_fn=print,
)
else:
pkg_manifest_remote = None
for pkg_manifest_remote_test in repo_cache_store.pkg_manifest_from_remote_ensure(
error_fn=print,
ignore_missing=True,
directory_subset=[repo_directory],
):
pkg_manifest_remote = pkg_manifest_remote_test
break
if pkg_manifest_remote is None: if pkg_manifest_remote is None:
return 0 return 0

@ -1627,7 +1627,7 @@ class _RepoCacheEntry:
*, *,
error_fn: Callable[[Exception], None], error_fn: Callable[[Exception], None],
force: bool = False, force: bool = False,
) -> None: ) -> Optional[Dict[str, PkgManifest_Normalized]]:
data = self._pkg_manifest_remote_data_source.data( data = self._pkg_manifest_remote_data_source.data(
cache_validate=True, cache_validate=True,
force=force, force=force,
@ -1641,6 +1641,8 @@ class _RepoCacheEntry:
if pkg_manifest_remote is not self._pkg_manifest_remote: if pkg_manifest_remote is not self._pkg_manifest_remote:
self._pkg_manifest_remote = pkg_manifest_remote self._pkg_manifest_remote = pkg_manifest_remote
return pkg_manifest_remote
def pkg_manifest_from_local_ensure( def pkg_manifest_from_local_ensure(
self, self,
*, *,
@ -1764,11 +1766,10 @@ class RepoCacheStore:
*, *,
error_fn: Callable[[Exception], None], error_fn: Callable[[Exception], None],
force: bool = False, force: bool = False,
) -> None: ) -> Optional[Dict[str, PkgManifest_Normalized]]:
for repo_entry in self._repos: for repo_entry in self._repos:
if directory == repo_entry.directory: if directory == repo_entry.directory:
repo_entry._json_data_refresh(force=force, error_fn=error_fn) return repo_entry._json_data_refresh(force=force, error_fn=error_fn)
return
raise ValueError("Directory {:s} not a known repo".format(directory)) raise ValueError("Directory {:s} not a known repo".format(directory))
def refresh_local_from_directory( def refresh_local_from_directory(