Check presence of repo address also.

BUG:FIXED:5940
This commit is contained in:
Faik Uygur
2008-08-07 07:22:52 +00:00
parent 09a0521cf9
commit 59e1cfcb67
2 changed files with 11 additions and 0 deletions
+3
View File
@@ -583,6 +583,9 @@ def add_repo(name, indexuri, at = None):
repodb = pisi.db.repodb.RepoDB()
if repodb.has_repo(name):
raise pisi.Error(_('Repo %s already present.') % name)
elif repodb.has_repo_url(indexuri):
repo = repodb.get_repo_by_url(indexuri)
raise pisi.Error(_('Repo already present with name %s.') % repo)
else:
repo = pisi.db.repodb.Repo(pisi.uri.URI(indexuri))
repodb.add_repo(name, repo, at = at)
+8
View File
@@ -166,3 +166,11 @@ class RepoDB(lazydb.LazyDB):
for r in self.list_repos():
repos.append(self.get_repo_url(r))
return repos
def get_repo_by_url(self, url):
if not self.has_repo_url(url):
return None
for r in self.list_repos():
if self.get_repo_url(r) == url:
return r