From 4539190af751b786d67ef5517d3828033ee999fb Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Thu, 27 Sep 2018 07:29:39 +0200 Subject: [PATCH] Optimize repository_state The _result view checks way more things than we need, so just iterate through the architectures of a repository and check the binaryversions per arch. And combine the sha1sums to one sha1 per repository --- osclib/core.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/osclib/core.py b/osclib/core.py index 0de8366c..151b71db 100644 --- a/osclib/core.py +++ b/osclib/core.py @@ -382,13 +382,20 @@ def repository_path_search(apiurl, project, search_project, search_repository): return None +def repository_arch_state(apiurl, project, repository, arch): + # just checking the mtimes of the repository's binaries + url = makeurl(apiurl, ['build', project, repository, arch, '_repository']) + from osclib.util import sha1_short + return sha1_short(http_GET(url).read()) + def repository_state(apiurl, project, repository): # Unfortunately, the state hash reflects the published state and not the # binaries published in repository. As such request binary list and hash. - url = makeurl(apiurl, ['build', project, '_result'], - {'view': 'binarylist', 'multibuild': 1, 'repository': repository}) + combined_state = [] + for arch in target_archs(apiurl, project, repository): + combined_state.append(repository_arch_state(apiurl, project, repository, arch)) from osclib.util import sha1_short - return sha1_short(http_GET(url).read()) + return sha1_short(combined_state) def repositories_states(apiurl, repository_pairs): states = []