diff --git a/osc-check_repo.py b/osc-check_repo.py index cb5d8f4e..483fe193 100644 --- a/osc-check_repo.py +++ b/osc-check_repo.py @@ -109,6 +109,7 @@ def _check_repo_download(self, request, opts): request.downloads = defaultdict(list) if request.is_cached: + request.downloads = self.checkrepo._get_downloads_from_local(request) print 'Found cached version for', request return set() @@ -269,7 +270,7 @@ def _check_repo_group(self, id_, requests, opts): params_file.write('\n'.join(f for f in toignore if f.strip())) params_file.close() - # If a package is in a Stagin Project, it will have in + # If a package is in a Staging Project, it will have in # request.downloads an entry for 'standard' (the repository of a # Staging Project) Also in this same field there will be another # valid repository (probably openSUSE_Factory) diff --git a/osclib/checkrepo.py b/osclib/checkrepo.py index 394bb625..e2b343d4 100644 --- a/osclib/checkrepo.py +++ b/osclib/checkrepo.py @@ -14,6 +14,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +from collections import defaultdict import os import subprocess from urllib import quote_plus @@ -473,8 +474,22 @@ class CheckRepo(object): def _get_goodrepos_from_local(self, request): """Calculate 'goodrepos' from local cache.""" project_dir = os.path.join(DOWNLOADS, request.src_package, request.src_project) - # This return the full list of firectories at this level. - return os.walk(project_dir).next()[1] + + # This return the full list of directories at this level. + goodrepos = os.walk(project_dir).next()[1] + return goodrepos + + def _get_downloads_from_local(self, request): + """Calculate 'downloads' from local cache.""" + project_dir = os.path.join(DOWNLOADS, request.src_package, request.src_project) + + downloads = defaultdict(list) + for dirpath, dirnames, filenames in os.walk(project_dir): + repo = os.path.basename(os.path.normpath(dirpath)) + if filenames: + downloads[repo] = [os.path.join(dirpath, f) for f in filenames] + + return downloads def is_buildsuccess(self, request): """Return True if the request is correctly build