From 59e1cfcb67a4ada5673bc2849c0884bf0c4b71d5 Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Thu, 7 Aug 2008 07:22:52 +0000 Subject: [PATCH] Check presence of repo address also. BUG:FIXED:5940 --- pisi/api.py | 3 +++ pisi/db/repodb.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/pisi/api.py b/pisi/api.py index 7f4157da..13da3d56 100644 --- a/pisi/api.py +++ b/pisi/api.py @@ -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) diff --git a/pisi/db/repodb.py b/pisi/db/repodb.py index f41f8284..7655dc23 100644 --- a/pisi/db/repodb.py +++ b/pisi/db/repodb.py @@ -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