repodb: Handle get_repo_doc and get_repo_url functions properly

When trying to retrieve the document or URL of a repo that does not exist, raise
appropriate exceptions.

BUG:FIXED:18681
This commit is contained in:
Metin Akdere
2011-11-11 13:42:14 +00:00
parent cbf8b2b18b
commit e79f6567ef
+6
View File
@@ -151,6 +151,9 @@ class RepoDB(lazydb.LazyDB):
return url in self.list_repo_urls(only_active)
def get_repo_doc(self, repo_name):
if not self.has_repo(repo_name):
raise RepoError(_("Repository %s does not exist.") % repo)
repo = self.get_repo(repo_name)
index_path = repo.indexuri.get_uri()
@@ -178,6 +181,9 @@ class RepoDB(lazydb.LazyDB):
#FIXME: this method is a quick hack around repo_info.indexuri.get_uri()
def get_repo_url(self, repo):
if not self.has_repo(repo):
raise RepoError(_("Repository %s does not exist.") % repo)
urifile_path = pisi.util.join_path(ctx.config.index_dir(), repo, "uri")
uri = open(urifile_path, "r").read()
return uri.rstrip()