Author: dmacvicar Date: Fri Jun 22 16:04:42 2007 New Revision: 5832 URL: http://svn.opensuse.org/viewcvs/zypp?rev=5832&view=rev Log: - implement modifyRepository (not tested, no testcase yet) Modified: branches/REFACTORING-10_3/libzypp/zypp/RepoManager.cc branches/REFACTORING-10_3/libzypp/zypp/RepoManager.h Modified: branches/REFACTORING-10_3/libzypp/zypp/RepoManager.cc URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/zypp/RepoManager.cc?rev=5832&r1=5831&r2=5832&view=diff ============================================================================== --- branches/REFACTORING-10_3/libzypp/zypp/RepoManager.cc (original) +++ branches/REFACTORING-10_3/libzypp/zypp/RepoManager.cc Fri Jun 22 16:04:42 2007 @@ -25,6 +25,7 @@ #include "zypp/cache/CacheStore.h" #include "zypp/repo/cached/RepoImpl.h" +#include "zypp/media/MediaManager.h" #include "zypp/MediaSetAccess.h" #include "zypp/parser/RepoFileReader.h" @@ -497,6 +498,12 @@ if ( access.doesFileExist("/content") ) return repo::RepoType::YAST2; + // if it is a local url + if ( ! media::MediaManager::downloads(url) ) + { + + } + return repo::RepoType("UNKNOWN"); } @@ -722,6 +729,64 @@ //////////////////////////////////////////////////////////////////////////// + void RepoManager::modifyRepository( const std::string &alias, + const RepoInfo & newinfo, + const ProgressData::ReceiverFnc & progressrcv ) + { + RepoInfo toedit = getRepositoryInfo(alias); + + if (toedit.filepath().empty()) + { + ZYPP_THROW(RepoException("Can't figure where the repo is stored")); + } + else + { + // figure how many repos are there in the file: + std::list<RepoInfo> filerepos = repositories_in_file(toedit.filepath()); + + // there are more repos in the same file + // write them back except the deleted one. + //TmpFile tmp; + //std::ofstream file(tmp.path().c_str()); + std::ofstream file(toedit.filepath().c_str()); + if (!file) { + //ZYPP_THROW (Exception( "Can't open " + tmp.path().asString() ) ); + ZYPP_THROW (Exception( "Can't open " + toedit.filepath().asString() ) ); + } + for ( std::list<RepoInfo>::const_iterator fit = filerepos.begin(); + fit != filerepos.end(); + ++fit ) + { + // if the alias is different, dump the original + // if it is the same, dump the provided one + if ( (*fit).alias() != toedit.alias() ) + (*fit).dumpRepoOn(file); + else + toedit.dumpRepoOn(file); + } + } + } + + //////////////////////////////////////////////////////////////////////////// + + RepoInfo RepoManager::getRepositoryInfo( const std::string &alias, + const ProgressData::ReceiverFnc & progressrcv ) + { + std::list<RepoInfo> repos = knownRepositories(); + for ( std::list<RepoInfo>::const_iterator it = repos.begin(); + it != repos.end(); + ++it ) + { + if ( (*it).alias() == alias ) + return *it; + } + RepoInfo info; + info.setAlias(info.alias()); + ZYPP_THROW(RepoNotFoundException(info)); + } + + //////////////////////////////////////////////////////////////////////////// + std::ostream & operator<<( std::ostream & str, const RepoManager & obj ) { return str << *obj._pimpl; Modified: branches/REFACTORING-10_3/libzypp/zypp/RepoManager.h URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/zypp/RepoManager.h?rev=5832&r1=5831&r2=5832&view=diff ============================================================================== --- branches/REFACTORING-10_3/libzypp/zypp/RepoManager.h (original) +++ branches/REFACTORING-10_3/libzypp/zypp/RepoManager.h Fri Jun 22 16:04:42 2007 @@ -169,6 +169,9 @@ /** * \short Create a repository object from the cache data * + * Creating from cache requires that the repository is + * refreshed (metadata downloaded) and cached + * * \throw RepoNotCachedException When the source is not cached. */ Repository createFromCache( const RepoInfo &info, @@ -217,6 +220,30 @@ void removeRepository( const RepoInfo & info, const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() ); + /** + * \short Modify repository attributes + * + * \throws RepoNotFoundException If no repo match + * \throws ParseException If the file parsing fails + * \throws Exception On other errors. + */ + void modifyRepository( const std::string &alias, + const RepoInfo & newinfo, + const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() ); + + /** + * \short Find a matching repository info + * + * \note if multple repositories incorrectly share the + * same alias, the first one found will be returned. + * + * \throws RepoNotFoundException If no repo match + * \throws ParseException If the file parsing fails + * \throws Exception On other errors. + */ + RepoInfo getRepositoryInfo( const std::string &alias, + const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() ); + protected: RepoStatus rawMetadataStatus( const RepoInfo &info ); RepoStatus cacheStatus( const RepoInfo &info ); -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org