~thopiekar/zypper/libzypp-manual-import

« back to all changes in this revision

Viewing changes to zypp/RepoManager.cc

  • Committer: Thomas-Karl Pietrowski
  • Date: 2015-08-15 15:59:50 UTC
  • Revision ID: thopiekar@googlemail.com-20150815155950-j66qn38efmvn289t
syncing with "changes 15.13.0 (11)"  #9a0aca7e3a21d768491b141a8ae86ef0c3fbc227
* https://github.com/openSUSE/libzypp/commit/9a0aca7e3a21d768491b141a8ae86ef0c3fbc227

Show diffs side-by-side

added added

removed removed

Lines of Context:
1012
1012
                                        "Valid metadata not found at specified URLs",
1013
1013
                                        info.baseUrlsSize() ) );
1014
1014
 
 
1015
    // Suppress (interactive) media::MediaChangeReport if we in have multiple basurls (>1)
 
1016
    media::ScopedDisableMediaChangeReport guard( info.baseUrlsSize() > 1 );
 
1017
 
1015
1018
    // try urls one by one
1016
1019
    for ( RepoInfo::urls_const_iterator it = info.baseUrlsBegin(); it != info.baseUrlsEnd(); ++it )
1017
1020
    {
1185
1188
      if ( cache_status == raw_metadata_status )
1186
1189
      {
1187
1190
        MIL << info.alias() << " cache is up to date with metadata." << endl;
1188
 
        if ( policy == BuildIfNeeded ) {
1189
 
          return;
 
1191
        if ( policy == BuildIfNeeded )
 
1192
        {
 
1193
          // On the fly add missing solv.idx files for bash completion.
 
1194
          const Pathname & base = solv_path_for_repoinfo( _options, info);
 
1195
          if ( ! PathInfo(base/"solv.idx").isExist() )
 
1196
            sat::updateSolvFileIndex( base/"solv" );
 
1197
 
 
1198
          return;
1190
1199
        }
1191
1200
        else {
1192
1201
          MIL << info.alias() << " cache rebuild is forced" << endl;
1290
1299
 
1291
1300
        // We keep it.
1292
1301
        guard.resetDispose();
 
1302
        sat::updateSolvFileIndex( solvfile );   // content digest for zypper bash completion
1293
1303
      }
1294
1304
      break;
1295
1305
      default:
1772
1782
            newinfo.dumpAsIniOn(file);
1773
1783
      }
1774
1784
 
 
1785
      if ( toedit.enabled() && !newinfo.enabled() )
 
1786
      {
 
1787
        // On the fly remove solv.idx files for bash completion if a repo gets disabled.
 
1788
        const Pathname & solvidx = solv_path_for_repoinfo(_options, newinfo)/"solv.idx";
 
1789
        if ( PathInfo(solvidx).isExist() )
 
1790
          filesystem::unlink( solvidx );
 
1791
      }
 
1792
 
1775
1793
      newinfo.setFilepath(toedit.filepath());
1776
1794
      reposManip().erase(toedit);
1777
1795
      reposManip().insert(newinfo);
1922
1940
    ServiceInfo service( getService( alias ) );
1923
1941
    assert_alias( service );
1924
1942
    assert_url( service );
 
1943
    MIL << "Going to refresh service '" << service.alias() <<  "', url: " << service.url() << ", opts: " << options_r << endl;
 
1944
 
 
1945
    if ( service.ttl() && !options_r.testFlag( RefreshService_forceRefresh ) )
 
1946
    {
 
1947
      // Service defines a TTL; maybe we can re-use existing data without refresh.
 
1948
      Date lrf = service.lrf();
 
1949
      if ( lrf )
 
1950
      {
 
1951
        Date now( Date::now() );
 
1952
        if ( lrf <= now )
 
1953
        {
 
1954
          if ( (lrf+=service.ttl()) > now ) // lrf+= !
 
1955
          {
 
1956
            MIL << "Skip: '" << service.alias() << "' metadata valid until " << lrf << endl;
 
1957
            return;
 
1958
          }
 
1959
        }
 
1960
        else
 
1961
          WAR << "Force: '" << service.alias() << "' metadata last refresh in the future: " << lrf << endl;
 
1962
      }
 
1963
    }
 
1964
 
1925
1965
    // NOTE: It might be necessary to modify and rewrite the service info.
1926
1966
    // Either when probing the type, or when adjusting the repositories
1927
1967
    // enable/disable state.:
1928
1968
    bool serviceModified = false;
1929
 
    MIL << "Going to refresh service '" << service.alias() << "', url: "<< service.url() << ", opts: " << options_r << endl;
1930
1969
 
1931
 
    //! \todo add callbacks for apps (start, end, repo removed, repo added, repo changed)
 
1970
    //! \todo add callbacks for apps (start, end, repo removed, repo added, repo changed)?
1932
1971
 
1933
1972
    // if the type is unknown, try probing.
1934
1973
    if ( service.type() == repo::ServiceType::NONE )
1950
1989
    DBG << "ServicesTargetDistro: " << servicesTargetDistro << endl;
1951
1990
 
1952
1991
    // parse it
 
1992
    Date::Duration origTtl = service.ttl();     // FIXME Ugly hack: const service.ttl modified when parsing
1953
1993
    RepoCollector collector(servicesTargetDistro);
1954
1994
    // FIXME Ugly hack: ServiceRepos may throw ServicePluginInformalException
1955
1995
    // which is actually a notification. Using an exception for this
1957
1997
    // and in zypper.
1958
1998
    std::pair<DefaultIntegral<bool,false>, repo::ServicePluginInformalException> uglyHack;
1959
1999
    try {
1960
 
      ServiceRepos repos(service, bind( &RepoCollector::collect, &collector, _1 ));
 
2000
      ServiceRepos( service, bind( &RepoCollector::collect, &collector, _1 ) );
1961
2001
    }
1962
2002
    catch ( const repo::ServicePluginInformalException & e )
1963
2003
    {
1965
2005
      uglyHack.first = true;
1966
2006
      uglyHack.second = e;
1967
2007
    }
1968
 
 
 
2008
    if ( service.ttl() != origTtl )     // repoindex.xml changed ttl
 
2009
    {
 
2010
      if ( !service.ttl() )
 
2011
        service.setLrf( Date() );       // don't need lrf when zero ttl
 
2012
      serviceModified = true;
 
2013
    }
1969
2014
    ////////////////////////////////////////////////////////////////////////////
1970
2015
    // On the fly remember the new repo states as defined the reopoindex.xml.
1971
2016
    // Move into ServiceInfo later.
1985
2030
      // if the repo url was not set by the repoindex parser, set service's url
1986
2031
      Url url;
1987
2032
      if ( it->baseUrlsEmpty() )
1988
 
        url = service.url();
 
2033
        url = service.rawUrl();
1989
2034
      else
1990
2035
      {
1991
2036
        // service repo can contain only one URL now, so no need to iterate.
2196
2241
 
2197
2242
    ////////////////////////////////////////////////////////////////////////////
2198
2243
    // save service if modified: (unless a plugin service)
2199
 
    if ( serviceModified && service.type() != ServiceType::PLUGIN )
 
2244
    if ( service.type() != ServiceType::PLUGIN )
2200
2245
    {
2201
 
      // write out modified service file.
2202
 
      modifyService( service.alias(), service );
 
2246
      if ( service.ttl() )
 
2247
      {
 
2248
        service.setLrf( Date::now() );  // remember last refresh
 
2249
        serviceModified =  true;        // or use a cookie file
 
2250
      }
 
2251
 
 
2252
      if ( serviceModified )
 
2253
      {
 
2254
        // write out modified service file.
 
2255
        modifyService( service.alias(), service );
 
2256
      }
2203
2257
    }
2204
2258
 
2205
2259
    if ( uglyHack.first )