Evaluate SolvAttr::repositoryToolVersion to prevent loading outdated solv files.
authorMichael Andres <ma@suse.de>
Tue, 19 Jan 2010 13:49:36 +0000 (14:49 +0100)
committerMichael Andres <ma@suse.de>
Tue, 19 Jan 2010 13:49:36 +0000 (14:49 +0100)
zypp/RepoManager.cc

index 66c4a21..7a85ddd 100644 (file)
@@ -1304,7 +1304,21 @@ namespace zypp
 
     try
     {
-      sat::Pool::instance().addRepoSolv( solvfile, info );
+      Repository repo = sat::Pool::instance().addRepoSolv( solvfile, info );
+      // test toolversion in order to rebuild solv file in case
+      // it was written by an old satsolver-tool parser.
+      //
+      // Known version strings used:
+      //  - <no string>
+      //  - "1.0"
+      //
+      sat::LookupRepoAttr toolversion( sat::SolvAttr::repositoryToolVersion, repo );
+      if ( toolversion.begin().asString().empty() )
+      {
+        repo.eraseFromPool();
+        ZYPP_THROW(Exception("Solv-file was created by old parser."));
+      }
+      // else: up-to-date (or even newer).
     }
     catch ( const Exception & exp )
     {