ref: refs/heads/master
commit 2f5d3b5786f5ebb2fc51eb32dac63d7cb14e605d
Author: Michael Andres
Date: Mon Oct 19 14:11:24 2009 +0200
Repository::setInfo: Propagate priority changes to avoid reloading the whole repo (bnc #498266).
---
zypp/Repository.cc | 10 ----------
zypp/sat/detail/PoolImpl.cc | 31 +++++++++++++++++++++++++++++++
zypp/sat/detail/PoolImpl.h | 5 ++---
3 files changed, 33 insertions(+), 13 deletions(-)
diff --git a/zypp/Repository.cc b/zypp/Repository.cc
index a72bce6..d7c7f53 100644
--- a/zypp/Repository.cc
+++ b/zypp/Repository.cc
@@ -17,7 +17,6 @@
#include "zypp/AutoDispose.h"
#include "zypp/Pathname.h"
-#include "zypp/media/MediaPriority.h"
#include "zypp/sat/detail/PoolImpl.h"
#include "zypp/Repository.h"
@@ -199,15 +198,6 @@ namespace zypp
info_r.alias().c_str(), alias().c_str() ) ) );
}
myPool().setRepoInfo( _repo, info_r );
-
- // satsolver priority is based on '<', while yum's repoinfo
- // uses 1(highest)->99(lowest). Thus we use -info_r.priority.
- _repo->priority = -info_r.priority();
-
- // subpriority is used to e.g. prefer http over dvd iff
- // both have same priority.
- _repo->subpriority = media::MediaPriority( info_r.url() );
-
MIL << *this << endl;
}
diff --git a/zypp/sat/detail/PoolImpl.cc b/zypp/sat/detail/PoolImpl.cc
index f35bee4..c969fd4 100644
--- a/zypp/sat/detail/PoolImpl.cc
+++ b/zypp/sat/detail/PoolImpl.cc
@@ -29,6 +29,7 @@
#include "zypp/PoolItem.h"
#include "zypp/target/modalias/Modalias.h"
+#include "zypp/media/MediaPriority.h"
extern "C"
{
@@ -347,6 +348,36 @@ namespace zypp
return ::repo_add_solvable_block( repo_r, count_r );
}
+ void PoolImpl::setRepoInfo( RepoIdType id_r, const RepoInfo & info_r )
+ {
+ ::_Repo * repo( getRepo( id_r ) );
+ if ( repo )
+ {
+ bool dirty = false;
+
+ // satsolver priority is based on '<', while yum's repoinfo
+ // uses 1(highest)->99(lowest). Thus we use -info_r.priority.
+ if ( repo->priority != -info_r.priority() )
+ {
+ repo->priority = -info_r.priority();
+ dirty = true;
+ }
+
+ // subpriority is used to e.g. prefer http over dvd iff
+ // both have same priority.
+ int mediaPriority( media::MediaPriority( info_r.url() ) );
+ if ( repo->subpriority != mediaPriority )
+ {
+ repo->subpriority = mediaPriority;
+ dirty = true;
+ }
+
+ if ( dirty )
+ setDirty(__FUNCTION__, info_r.alias().c_str() );
+ }
+ _repoinfos[id_r] = info_r;
+ }
+
///////////////////////////////////////////////////////////////////
// need on demand and id based Locale
diff --git a/zypp/sat/detail/PoolImpl.h b/zypp/sat/detail/PoolImpl.h
index 003cc35..ade5a97 100644
--- a/zypp/sat/detail/PoolImpl.h
+++ b/zypp/sat/detail/PoolImpl.h
@@ -177,9 +177,8 @@ namespace zypp
/** */
const RepoInfo & repoInfo( RepoIdType id_r )
{ return _repoinfos[id_r]; }
- /** */
- void setRepoInfo( RepoIdType id_r, const RepoInfo & info_r )
- { _repoinfos[id_r] = info_r; }
+ /** Also adjust repo priority and subpriority accordingly. */
+ void setRepoInfo( RepoIdType id_r, const RepoInfo & info_r );
/** */
void eraseRepoInfo( RepoIdType id_r )
{ _repoinfos.erase( id_r ); }
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org