- fixed renaming a repo to an existing one (bnc #228216)
authorJan Kupec <jkupec@suse.cz>
Fri, 1 Feb 2008 16:45:00 +0000 (16:45 +0000)
committerJan Kupec <jkupec@suse.cz>
Fri, 1 Feb 2008 16:45:00 +0000 (16:45 +0000)
zypp/RepoManager.cc
zypp/RepoManager.h

index 9bab4e6..14d44af 100644 (file)
@@ -1114,6 +1114,19 @@ namespace zypp
   {
     RepoInfo toedit = getRepositoryInfo(alias);
 
+    // check if the new alias already exists when renaming the repo
+    if (alias != newinfo.alias())
+    {
+      std::list<RepoInfo> repos = knownRepositories();
+      for ( std::list<RepoInfo>::const_iterator it = repos.begin();
+            it != repos.end();
+            ++it )
+      {
+        if ( newinfo.alias() == (*it).alias() )
+          ZYPP_THROW(RepoAlreadyExistsException(newinfo.alias()));
+      }
+    }
+
     if (toedit.filepath().empty())
     {
       ZYPP_THROW(RepoException("Can't figure where the repo is stored"));
index 6708698..eb2f24e 100644 (file)
@@ -325,6 +325,8 @@ namespace zypp
     /**
      * \short Modify repository attributes
      *
+     * \throws RepoAlreadyExistsException if the alias specified in newinfo
+     *         is already used by another repository
      * \throws RepoNotFoundException If no repo match
      * \throws ParseException If the file parsing fails
      * \throws Exception On other errors.