add url_filter
authorKlaus Kaempf <kkaempf@suse.de>
Mon, 12 Jun 2006 12:26:04 +0000 (12:26 +0000)
committerKlaus Kaempf <kkaempf@suse.de>
Mon, 12 Jun 2006 12:26:04 +0000 (12:26 +0000)
zypp/SourceManager.cc
zypp/SourceManager.h

index 17202e8..b605e7e 100644 (file)
@@ -321,10 +321,11 @@ namespace zypp
   /** \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());
@@ -341,12 +342,18 @@ namespace zypp
 
     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;
   
index db70632..166a7ad 100644 (file)
@@ -170,12 +170,18 @@ namespace zypp
      * \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