From bf35da3c6cbd30a73aa69c9734a06e97a035ecb2 Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Fri, 1 Jun 2007 14:12:55 +0000 Subject: [PATCH] backup --- zypp2/RepoManager.cc | 42 ++++++++++++++++++++++++++++- zypp2/RepoManager.h | 62 ++++++++++++++++++++++++++++++++++++++++--- zypp2/repo/RepoException.h | 4 +-- zypp2/repo/RepositoryImpl.cc | 14 +++++++++- zypp2/repo/RepositoryImpl.h | 32 +++++++++++++++++++--- zypp2/repo/cached/RepoImpl.cc | 6 ----- zypp2/repo/cached/RepoImpl.h | 38 +++----------------------- 7 files changed, 146 insertions(+), 52 deletions(-) diff --git a/zypp2/RepoManager.cc b/zypp2/RepoManager.cc index b4f4ad5..26926f0 100644 --- a/zypp2/RepoManager.cc +++ b/zypp2/RepoManager.cc @@ -13,16 +13,17 @@ #include #include #include -#include "zypp/base/Exception.h" #include "zypp/base/InputStream.h" #include "zypp/base/Logger.h" #include "zypp/PathInfo.h" #include "zypp/parser/IniDict.h" +#include "zypp2/repo/RepoException.h" #include "zypp2/RepoManager.h" using namespace std; using namespace zypp; +using namespace zypp::repo; using namespace zypp::filesystem; using parser::IniDict; @@ -170,6 +171,45 @@ namespace zypp RepoManager::~RepoManager() {} + static void assert_alias( const RepoInfo &info ) + { + if (info.alias().empty()) + ZYPP_THROW(RepoNoAliasException()); + } + + static Pathname rawcache_path_for_alias( const RepoManagerOptions &opt, const string &alias ) + { + //repoRawCachePath + return Pathname(); + } + + void RepoManager::refreshMetadata( const RepoInfo &info ) + { + assert_alias(info); + + + } + + void RepoManager::cleanMetadata( const RepoInfo &info ) + { + + } + + void RepoManager::buildCache( const RepoInfo &info ) + { + + } + + void RepoManager::cleanCache( const RepoInfo &info ) + { + + } + + Repository RepoManager::createFromCache( const RepoInfo &info ) + { + return Repository::noRepository; + } + /****************************************************************** ** ** FUNCTION NAME : operator<< diff --git a/zypp2/RepoManager.h b/zypp2/RepoManager.h index 9d43ca4..7ee7ecd 100644 --- a/zypp2/RepoManager.h +++ b/zypp2/RepoManager.h @@ -20,7 +20,7 @@ //#include "zypp/base/NonCopyable.h" #include "zypp/Pathname.h" #include "zypp/ZConfig.h" - +#include "zypp2/Repository.h" #include "zypp2/RepoInfo.h" #include "zypp2/repo/RepoException.h" @@ -55,7 +55,9 @@ namespace zypp public: RepoManager( const RepoManagerOptions &options = RepoManagerOptions() ); - + /** Dtor */ + ~RepoManager(); + /** * \short List known repositories. * @@ -66,8 +68,60 @@ namespace zypp */ std::list knownRepositories(); - /** Dtor */ - ~RepoManager(); + /** + * \short Refresh local cache + * + * Will try to download the metadata + * + * \throws RepoNoUrl if no urls are available. + * \throws RepoNoAlias if can't figure an alias + * \throws Exception on unknown error. + */ + void refreshMetadata( const RepoInfo &info ); + + /** + * \short Clean local metadata + * + * Empty local metadata. + * + * \throws RepoNoAlias if can't figure an alias + * \throws Exception on unknown error. + */ + void cleanMetadata( const RepoInfo &info ); + + /** + * \short Refresh local cache + * + * Will try to build the cache from + * local metadata. + * + * If the cache exists it will be overwriten. + * + * \note the local metadata must be valid. + * + * \throws RepoNoAlias if can't figure an alias to look in cache + * \throws Exception on unknown error. + */ + void buildCache( const RepoInfo &info ); + + /** + * \short clean local cache + * + * Clean the cached version of the metadata + * + * \note the local metadata must be valid. + * + * \throws RepoNoAlias if can't figure an alias to look in cache + * \throws Exception on unknown error. + */ + void cleanCache( const RepoInfo &info ); + + /** + * \short Create a repository object from the cache data + * + * \throw RepoNotCachedException When the source is not cached. + */ + Repository createFromCache( const RepoInfo &info ); public: diff --git a/zypp2/repo/RepoException.h b/zypp2/repo/RepoException.h index acb8a63..d2c851b 100644 --- a/zypp2/repo/RepoException.h +++ b/zypp2/repo/RepoException.h @@ -56,7 +56,7 @@ namespace zypp * thrown when it was impossible to * determine one url for this repo. */ - class RepoNoUrl : public RepoException + class RepoNoUrlException : public RepoException { }; @@ -65,7 +65,7 @@ namespace zypp * thrown when it was impossible to * determine an alias for this repo. */ - class RepoNoAlias : public RepoException + class RepoNoAliasException : public RepoException { }; diff --git a/zypp2/repo/RepositoryImpl.cc b/zypp2/repo/RepositoryImpl.cc index 8470bd2..4d842c6 100644 --- a/zypp2/repo/RepositoryImpl.cc +++ b/zypp2/repo/RepositoryImpl.cc @@ -5,11 +5,17 @@ namespace zypp { namespace repo { IMPL_PTR_TYPE(RepositoryImpl) -RepositoryImpl::RepositoryImpl() +RepositoryImpl::RepositoryImpl( const RepoInfo &info ) + : _info(info) { } +const RepoInfo RepositoryImpl::info() const +{ + return _info; +} + RepositoryImpl::~RepositoryImpl() { @@ -19,5 +25,11 @@ RepositoryImpl::RepositoryImpl( const null & ) : base::ProvideNumericId( NULL ) {} + +const ResStore & RepositoryImpl::resolvables() const +{ + return _store; +} + } } // ns diff --git a/zypp2/repo/RepositoryImpl.h b/zypp2/repo/RepositoryImpl.h index cbdb632..fb333ba 100644 --- a/zypp2/repo/RepositoryImpl.h +++ b/zypp2/repo/RepositoryImpl.h @@ -10,7 +10,10 @@ #include "zypp/base/NonCopyable.h" #include "zypp/base/PtrTypes.h" #include "zypp/base/ProvideNumericId.h" +#include "zypp/ResStore.h" #include "zypp2/Repository.h" +#include "zypp2/RepoInfo.h" + /////////////////////////////////////////////////////////////////// namespace zypp { ///////////////////////////////////////////////////////////////// @@ -21,15 +24,33 @@ namespace zypp DEFINE_PTR_TYPE(RepositoryImpl); class RepositoryImpl : public base::ReferenceCounted, - public base::ProvideNumericId, - private base::NonCopyable + public base::ProvideNumericId, + private base::NonCopyable { friend std::ostream & operator<<( std::ostream & str, const RepositoryImpl & obj ); public: - RepositoryImpl(); + /** + * \short Ctor. + * \param info What is known about this source at construction time. + * + */ + RepositoryImpl( const RepoInfo &info = RepoInfo() ); + + /** + * \short Information about this repository + * You can't change this information after creation. + * Use \ref RepoManager for that. + */ + const RepoInfo info() const; + + /** + * \short Dtor + */ ~RepositoryImpl(); + const ResStore & resolvables() const; + struct null {}; public: /** Offer default Impl. */ @@ -43,8 +64,11 @@ namespace zypp Repository selfRepository() { return Repository( this ); } + protected: + RepoInfo _info; + + ResStore _store; }; - } } diff --git a/zypp2/repo/cached/RepoImpl.cc b/zypp2/repo/cached/RepoImpl.cc index ea3037e..b6b44ee 100644 --- a/zypp2/repo/cached/RepoImpl.cc +++ b/zypp2/repo/cached/RepoImpl.cc @@ -178,12 +178,6 @@ void RepoImpl::read_capabilities( sqlite3_connection &con, map &nvras ); - + Pathname _dbdir; cache::CacheTypes _type_cache; data::RecordId _repository_id; -- 2.7.4