Imported Upstream version 16.0.3
[platform/upstream/libzypp.git] / zypp / sat / detail / PoolImpl.cc
index 5a5de13..89936d3 100644 (file)
@@ -91,6 +91,8 @@ namespace zypp
 
       /////////////////////////////////////////////////////////////////
 
+      const bool resusePoolIDs = true;
+
       const std::string & PoolImpl::systemRepoAlias()
       {
         static const std::string _val( "@System" );
@@ -103,7 +105,6 @@ namespace zypp
        return _val;
       }
 
-
       /////////////////////////////////////////////////////////////////
 
       static void logSat( CPool *, void *data, int type, const char *logString )
@@ -304,7 +305,9 @@ namespace zypp
        if ( isSystemRepo( repo_r ) )
          _autoinstalled.clear();
         eraseRepoInfo( repo_r );
-        ::repo_free( repo_r, /*reuseids*/false );
+        ::repo_free( repo_r, resusePoolIDs );
+       if ( resusePoolIDs && !_pool->urepos )  // If the last repo is removed clear the pool to actually reuse all IDs.
+         ::pool_freeallrepos( _pool, resusePoolIDs );
       }
 
       int PoolImpl::_addSolv( CRepo * repo_r, FILE * file_r )
@@ -356,14 +359,14 @@ namespace zypp
               else if ( blockSize )
               {
                 // Free remembered entries
-                  ::repo_free_solvable_block( repo_r, blockBegin, blockSize, /*reuseids*/false );
+                  ::repo_free_solvable_block( repo_r, blockBegin, blockSize, resusePoolIDs );
                   blockBegin = blockSize = 0;
               }
           }
           if ( blockSize )
           {
               // Free remembered entries
-              ::repo_free_solvable_block( repo_r, blockBegin, blockSize, /*reuseids*/false );
+              ::repo_free_solvable_block( repo_r, blockBegin, blockSize, resusePoolIDs );
               blockBegin = blockSize = 0;
           }
         }