/** \todo Broken design: either use return value or Exception to
* indicate errors, not both.
*/
- bool SourceManager::restore( Pathname root_r, bool use_caches, const std::string &alias_filter )
+ bool SourceManager::restore( Pathname root_r, bool use_caches, const std::string &alias_filter, const std::string &url_filter )
{
MIL << "SourceManager restore ('" << root_r << ( use_caches ? "' (use_caches)" : "'" )
- << ", alias_filter '" << alias_filter << "')" << endl;
+ << ", alias_filter '" << alias_filter
+ << ", url_filter '" << url_filter << "')" << endl;
if (! _sources.empty() )
ZYPP_THROW(SourcesAlreadyRestoredException());
for( std::list<storage::PersistentStorage::SourceData>::iterator it = new_sources.begin(); it != new_sources.end(); ++it)
{
- if ( !alias_filter.empty() // check filter, if set
+ if ( !alias_filter.empty() // check alias filter, if set
&& (alias_filter != it->alias) )
{
continue;
}
+ if ( !url_filter.empty() // check url filter, if set
+ && (url_filter != it->url.asString()) )
+ {
+ continue;
+ }
+
// Note: Url(it->url).asString() to hide password in logs
MIL << "Restoring source: url:[" << Url(it->url).asString() << "] product_dir:[" << it->product_dir << "] alias:[" << it->alias << "] cache_dir:[" << it->cache_dir << "]" << endl;
* \param use_caches if true, source creation will try to use source cache
* and it's behavior on autorefresh. If false, it will not use
* the cache at all.
+ * \param alias_filter if non-empty, restore only a source matching
+ * this alias.
+ * \param url_filter if non-empty, restore only a source matching
+ * this url.
+ *
+ * The alias_filter take precedence over the url_filter.
*
* \return true on success
*
* \throws Exception
*/
- bool restore(Pathname root_r, bool use_caches = true, const std::string &alias_filter = "" );
+ bool restore(Pathname root_r, bool use_caches = true, const std::string &alias_filter = "", const std::string &url_filter = "" );
/**
* Find a source with a specified ID