Imported Upstream version 14.45.0
[platform/upstream/libzypp.git] / zypp / RepoManager.cc
index b830e85..3853444 100644 (file)
@@ -840,7 +840,7 @@ namespace zypp
       // Cleanup orphanded service repos:
       if ( ! orphanedRepos.empty() )
       {
-       for ( const auto & repoInfo : orphanedRepos )
+       for ( auto & repoInfo : orphanedRepos )
        {
          MIL << "Delete orphaned service repo " << repoInfo.alias() << endl;
          // translators: Cleanup a repository previously owned by a meanwhile unknown (deleted) service.
@@ -1079,7 +1079,7 @@ namespace zypp
     assert_urls(info);
 
     // we will throw this later if no URL checks out fine
-    RepoException rexception( info, PL_("Valid metadata not found at specified URL",
+    RepoException rexception( info, _PL("Valid metadata not found at specified URL",
                                        "Valid metadata not found at specified URLs",
                                        info.baseUrlsSize() ) );
 
@@ -1201,6 +1201,9 @@ namespace zypp
         // cause of the problem of the first URL remembered
         if (it == info.baseUrlsBegin())
           rexception.remember(e);
+       else
+         rexception.addHistory(  e.asUserString() );
+
       }
     } // for every url
     ERR << "No more urls..." << endl;
@@ -1259,14 +1262,8 @@ namespace zypp
       if ( cache_status == raw_metadata_status )
       {
         MIL << info.alias() << " cache is up to date with metadata." << endl;
-        if ( policy == BuildIfNeeded )
-       {
-         // On the fly add missing solv.idx files for bash completion.
-         const Pathname & base = solv_path_for_repoinfo( _options, info);
-         if ( ! PathInfo(base/"solv.idx").isExist() )
-           sat::updateSolvFileIndex( base/"solv" );
-
-         return;
+        if ( policy == BuildIfNeeded ) {
+          return;
         }
         else {
           MIL << info.alias() << " cache rebuild is forced" << endl;
@@ -1370,7 +1367,6 @@ namespace zypp
 
         // We keep it.
         guard.resetDispose();
-       sat::updateSolvFileIndex( solvfile );   // content digest for zypper bash completion
       }
       break;
       default:
@@ -1762,10 +1758,12 @@ namespace zypp
       {
         // figure how many repos are there in the file:
         std::list<RepoInfo> filerepos = repositories_in_file(todelete.filepath());
-        if ( (filerepos.size() == 1) && ( filerepos.front().alias() == todelete.alias() ) )
+        if ( filerepos.size() == 0     // bsc#984494: file may have already been deleted
+         ||(filerepos.size() == 1 && filerepos.front().alias() == todelete.alias() ) )
         {
-          // easy, only this one, just delete the file
-          if ( filesystem::unlink(todelete.filepath()) != 0 )
+          // easy: file does not exist, contains no or only the repo to delete: delete the file
+         int ret = filesystem::unlink( todelete.filepath() );
+          if ( ! ( ret == 0 || ret == ENOENT ) )
           {
             // TranslatorExplanation '%s' is a filename
             ZYPP_THROW(RepoException( todelete, str::form( _("Can't delete '%s'"), todelete.filepath().c_str() )));
@@ -1865,14 +1863,6 @@ namespace zypp
             newinfo.dumpAsIniOn(file);
       }
 
-      if ( toedit.enabled() && !newinfo.enabled() )
-      {
-       // On the fly remove solv.idx files for bash completion if a repo gets disabled.
-       const Pathname & solvidx = solv_path_for_repoinfo(_options, newinfo)/"solv.idx";
-       if ( PathInfo(solvidx).isExist() )
-         filesystem::unlink( solvidx );
-      }
-
       newinfo.setFilepath(toedit.filepath());
       reposManip().erase(toedit);
       reposManip().insert(newinfo);
@@ -2018,34 +2008,13 @@ namespace zypp
     ServiceInfo service( getService( alias ) );
     assert_alias( service );
     assert_url( service );
-    MIL << "Going to refresh service '" << service.alias() <<  "', url: " << service.url() << ", opts: " << options_r << endl;
-
-    if ( service.ttl() && !( options_r.testFlag( RefreshService_forceRefresh) || options_r.testFlag( RefreshService_restoreStatus ) ) )
-    {
-      // Service defines a TTL; maybe we can re-use existing data without refresh.
-      Date lrf = service.lrf();
-      if ( lrf )
-      {
-       Date now( Date::now() );
-       if ( lrf <= now )
-       {
-         if ( (lrf+=service.ttl()) > now ) // lrf+= !
-         {
-           MIL << "Skip: '" << service.alias() << "' metadata valid until " << lrf << endl;
-           return;
-         }
-       }
-       else
-         WAR << "Force: '" << service.alias() << "' metadata last refresh in the future: " << lrf << endl;
-      }
-    }
-
     // NOTE: It might be necessary to modify and rewrite the service info.
     // Either when probing the type, or when adjusting the repositories
     // enable/disable state.:
     bool serviceModified = false;
+    MIL << "Going to refresh service '" << service.alias() << "', url: "<< service.url() << ", opts: " << options_r << endl;
 
-    //! \todo add callbacks for apps (start, end, repo removed, repo added, repo changed)?
+    //! \todo add callbacks for apps (start, end, repo removed, repo added, repo changed)
 
     // if the type is unknown, try probing.
     if ( service.type() == repo::ServiceType::NONE )
@@ -2067,7 +2036,6 @@ namespace zypp
     DBG << "ServicesTargetDistro: " << servicesTargetDistro << endl;
 
     // parse it
-    Date::Duration origTtl = service.ttl();    // FIXME Ugly hack: const service.ttl modified when parsing
     RepoCollector collector(servicesTargetDistro);
     // FIXME Ugly hack: ServiceRepos may throw ServicePluginInformalException
     // which is actually a notification. Using an exception for this
@@ -2075,7 +2043,7 @@ namespace zypp
     // and in zypper.
     std::pair<DefaultIntegral<bool,false>, repo::ServicePluginInformalException> uglyHack;
     try {
-      ServiceRepos( service, bind( &RepoCollector::collect, &collector, _1 ) );
+      ServiceRepos repos(service, bind( &RepoCollector::collect, &collector, _1 ));
     }
     catch ( const repo::ServicePluginInformalException & e )
     {
@@ -2083,12 +2051,7 @@ namespace zypp
       uglyHack.first = true;
       uglyHack.second = e;
     }
-    if ( service.ttl() != origTtl )    // repoindex.xml changed ttl
-    {
-      if ( !service.ttl() )
-       service.setLrf( Date() );       // don't need lrf when zero ttl
-      serviceModified = true;
-    }
+
     ////////////////////////////////////////////////////////////////////////////
     // On the fly remember the new repo states as defined the reopoindex.xml.
     // Move into ServiceInfo later.
@@ -2351,19 +2314,10 @@ namespace zypp
 
     ////////////////////////////////////////////////////////////////////////////
     // save service if modified: (unless a plugin service)
-    if ( service.type() != ServiceType::PLUGIN )
+    if ( serviceModified && service.type() != ServiceType::PLUGIN )
     {
-      if ( service.ttl() )
-      {
-       service.setLrf( Date::now() );  // remember last refresh
-       serviceModified =  true;        // or use a cookie file
-      }
-
-      if ( serviceModified )
-      {
-       // write out modified service file.
-       modifyService( service.alias(), service );
-      }
+      // write out modified service file.
+      modifyService( service.alias(), service );
     }
 
     if ( uglyHack.first )