Mailinglist Archive: zypp-commit (223 mails)

< Previous Next >
[zypp-commit] r10669 - in /trunk/libzypp/zypp: RepoManager.cc RepoManager.h Service.cc
  • From: jkupec@xxxxxxxxxxxxxxxx
  • Date: Sun, 27 Jul 2008 11:33:17 -0000
  • Message-id: <20080727113318.060DE2A118@xxxxxxxxxxxxxxxx>
Author: jkupec
Date: Sun Jul 27 13:33:17 2008
New Revision: 10669

URL: http://svn.opensuse.org/viewcvs/zypp?rev=10669&view=rev
Log:
- fixed service removal

Modified:
trunk/libzypp/zypp/RepoManager.cc
trunk/libzypp/zypp/RepoManager.h
trunk/libzypp/zypp/Service.cc

Modified: trunk/libzypp/zypp/RepoManager.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/RepoManager.cc?rev=10669&r1=10668&r2=10669&view=diff
==============================================================================
--- trunk/libzypp/zypp/RepoManager.cc (original)
+++ trunk/libzypp/zypp/RepoManager.cc Sun Jul 27 13:33:17 2008
@@ -1328,7 +1328,7 @@
{
MIL << "Going to delete repo " << alias << endl;

- const Service& service = getService( alias );
+ const Service & service = getService( alias );

Pathname location = service.location();
if( location.empty() )
@@ -1342,7 +1342,8 @@
parser::ServiceFileReader reader( location,
bind(&Impl::ServiceCollector::collect,collector,_1) );

- if ( tmpSet.size() == 1 ) //only one record
+ // only one service definition in the file
+ if ( tmpSet.size() == 1 )
{
if ( filesystem::unlink(location) != 0 )
{
@@ -1367,13 +1368,21 @@
MIL << alias << " sucessfully deleted from file " << location << endl;
}

- //now remove all repositories added by this service
+ // now remove all repositories added by this service
+ RepoCollector rcollector;
getRepositoriesInService( alias,
boost::make_function_output_iterator(
- bind(&RepoManager::removeRepository, this, _1,
ProgressData::ReceiverFnc()) ) );
+ bind( &RepoCollector::collect, &rcollector, _1 ) ) );
+ // cannot do this directly in getRepositoriesInService - would invalidate
iterators
+ for_(rit, rcollector.repos.begin(), rcollector.repos.end())
+ removeRepository(*rit);
}


+ void RepoManager::removeService( const Service & service )
+ { removeService(service.alias()); }
+
+
void RepoManager::Impl::saveService( const Service & service ) const
{
filesystem::assert_dir( options.knownServicesPath );
@@ -1396,11 +1405,10 @@

Service RepoManager::getService( const std::string & alias ) const
{
- ServiceConstIterator it = _pimpl->services.find(alias);
- if ( it == serviceEnd() )
- return Service::noService;
- else
- return *it;
+ for_ (it, serviceBegin(), serviceEnd())
+ if ( it->alias() == alias )
+ return *it;
+ return Service::noService;
}

bool RepoManager::serviceEmpty() const { return _pimpl->services.empty(); }

Modified: trunk/libzypp/zypp/RepoManager.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/RepoManager.h?rev=10669&r1=10668&r2=10669&view=diff
==============================================================================
--- trunk/libzypp/zypp/RepoManager.h (original)
+++ trunk/libzypp/zypp/RepoManager.h Sun Jul 27 13:33:17 2008
@@ -474,6 +474,8 @@
*/
void removeService( const std::string & alias );

+ void removeService( const Service & service );
+
/**
* Gets true if no service is in RepoManager (so no one in specified
location)
*
@@ -556,39 +558,51 @@
};

public:
+
/**
* fill to output iterator repositories in service name. This output
iterator can perform
* any action on with Repo or service Container, because it is sets and it
isn't dynamic recreate.
- * \param name service name
- * \param out output iterator which get all repositories in Service
+ *
+ * \note Don't use this function with RepoManager::removeRepository(), it
will lead to segfaults
+ * due to invalidated internal iterators. FIXME can this be solved
(using STL) so that this
+ * warning would not be needed?
+ *
+ * \param alias service alias
+ * \param out output iterator which get all the repositories belonging to
+ * specified service
*
* example how set priority for each RepoInfo in this service:
* \code
* //functor
- * class ChangePriority{
- * private:
- * int priority;
- * public:
- * ChangePriority(int prio) : priority(prio) {}
- * void doIt( RepoInfo info ) { info.setPriority(priority); }
//missing rewrite priority back via RepoManager::modifyRepo
+ * class ChangePriority
+ * {
+ * private:
+ * int priority;
+ * public:
+ * ChangePriority(int prio) : priority(prio) {}
+ * // missing rewrite priority back via RepoManager::modifyRepo
+ * void doIt( RepoInfo info ) { info.setPriority(priority); }
* }
*
* //somewhere in code
* ChangePriority changer(10);
- * getRepositoriesInService(name,getRepositoriesInService( name,
boost::make_function_output_iterator(bind(&ChangePriority::doIt, &changer,
_1))));
+ * getRepositoriesInService(name,
+ * boost::make_function_output_iterator(
+ * bind(&ChangePriority::doIt, &changer, _1)));
* \endcode
*/
-
template<typename OutputIterator>
void getRepositoriesInService( const std::string & alias,
OutputIterator out ) const
{
MatchServiceAlias filter(alias);

- std::copy(boost::make_filter_iterator(bind(&MatchServiceAlias::match,
- filter, _1),repoBegin(),repoEnd()), boost::make_filter_iterator(
+ std::copy(
+ boost::make_filter_iterator(
+ bind(&MatchServiceAlias::match, filter, _1), repoBegin(), repoEnd()),
+ boost::make_filter_iterator(
bind(&MatchServiceAlias::match, filter, _1), repoEnd(), repoEnd()),
- out );
+ out);
}

protected:

Modified: trunk/libzypp/zypp/Service.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Service.cc?rev=10669&r1=10668&r2=10669&view=diff
==============================================================================
--- trunk/libzypp/zypp/Service.cc (original)
+++ trunk/libzypp/zypp/Service.cc Sun Jul 27 13:33:17 2008
@@ -83,12 +83,10 @@

void Service::dumpServiceOn( std::ostream& str ) const
{
- str << endl;
str << "[" << alias() << "]" << endl;
str << "name = " << name() << endl;
str << "url = " << url() << endl;
str << "enabled = " << ( enabled() ? "1" : "0") << endl;
- str << endl;
}

Pathname Service::location() const

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages