r8431 | jkupec | 2008-02-01 17:45:00 +0100 (Fr, 01 Feb 2008) | 2 lines
authorStephan Kulow <coolo@suse.de>
Fri, 8 Feb 2008 09:14:10 +0000 (09:14 +0000)
committerStephan Kulow <coolo@suse.de>
Fri, 8 Feb 2008 09:14:10 +0000 (09:14 +0000)
   - fixed renaming a repo to an existing one (bnc #228216)

zypp/RepoManager.cc
zypp/RepoManager.h

index 1406bfd..cd8c52c 100644 (file)
@@ -1168,6 +1168,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 a958700..2303461 100644 (file)
@@ -311,6 +311,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.