]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-item.cc
* merged the apt--mirror branch
[apt.git] / apt-pkg / acquire-item.cc
index 61564c7aa0fabc1b82b13add1c2fd4707e3432c1..3be7878bf58f307266ba116163d94de75d4bfc64 100644 (file)
@@ -63,6 +63,7 @@ void pkgAcquire::Item::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
 {
    Status = StatIdle;
    ErrorText = LookupTag(Message,"Message");
+   UsedMirror =  LookupTag(Message,"UsedMirror");
    if (QueueCounter <= 1)
    {
       /* This indicates that the file is not available right now but might
@@ -75,13 +76,16 @@ void pkgAcquire::Item::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
         Dequeue();
         return;
       }
-      
+
       Status = StatError;
       Dequeue();
    }   
    
    // report mirror failure back to LP if we actually use a mirror
-   if(!UsedMirror.empty())
+   string FailReason = LookupTag(Message, "FailReason");
+   if(FailReason.size() != 0)
+      ReportMirrorFailure(FailReason);
+   else
       ReportMirrorFailure(ErrorText);
 }
                                                                        /*}}}*/
@@ -137,22 +141,27 @@ void pkgAcquire::Item::Rename(string From,string To)
 
 void pkgAcquire::Item::ReportMirrorFailure(string FailCode)
 {
-   // report that Queue->Uri failed
+   // we only act if a mirror was used at all
+   if(UsedMirror.empty())
+      return;
 #if 0
    std::cerr << "\nReportMirrorFailure: " 
             << UsedMirror
+            << " Uri: " << DescURI()
             << " FailCode: " 
             << FailCode << std::endl;
 #endif
    const char *Args[40];
    unsigned int i = 0;
    string report = _config->Find("Methods::Mirror::ProblemReporting", 
-                                "/usr/bin/apt-report-mirror-failure");
+                                "/usr/lib/apt/apt-report-mirror-failure");
    if(!FileExists(report))
       return;
    Args[i++] = report.c_str();
    Args[i++] = UsedMirror.c_str();
+   Args[i++] = DescURI().c_str();
    Args[i++] = FailCode.c_str();
+   Args[i++] = NULL;
    pid_t pid = ExecFork();
    if(pid < 0) 
    {
@@ -161,12 +170,14 @@ void pkgAcquire::Item::ReportMirrorFailure(string FailCode)
    }
    else if(pid == 0) 
    {
-      execvp(report.c_str(), (char**)Args);
+      execvp(Args[0], (char**)Args);
+      std::cerr << "Could not exec " << Args[0] << std::endl;
+      _exit(100);
    }
    if(!ExecWait(pid, "report-mirror-failure")) 
    {
       _error->Warning("Couldn't report problem to '%s'",
-                     _config->Find("Acquire::Mirror::ReportFailures").c_str());
+                     _config->Find("Methods::Mirror::ProblemReporting").c_str());
    }
 }
 
@@ -274,6 +285,7 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string MD5,
          Status = StatAuthError;
          ErrorText = _("MD5Sum mismatch");
          Rename(DestFile,DestFile + ".FAILED");
+        ReportMirrorFailure("HashChecksumFailure");
          return;
       }
       // Done, move it into position
@@ -347,6 +359,35 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string MD5,
    Mode = decompProg;
 }
 
+// AcqIndexTrans::pkgAcqIndexTrans - Constructor                       /*{{{*/
+// ---------------------------------------------------------------------
+/* The Translation file is added to the queue */
+pkgAcqIndexTrans::pkgAcqIndexTrans(pkgAcquire *Owner,
+                           string URI,string URIDesc,string ShortDesc) :
+                      pkgAcqIndex(Owner, URI, URIDesc, ShortDesc, "", "")
+{
+}
+
+                                                                       /*}}}*/
+// AcqIndexTrans::Failed - Silence failure messages for missing files  /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+void pkgAcqIndexTrans::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
+{
+   if (Cnf->LocalOnly == true || 
+       StringToBool(LookupTag(Message,"Transient-Failure"),false) == false)
+   {      
+      // Ignore this
+      Status = StatDone;
+      Complete = false;
+      Dequeue();
+      return;
+   }
+   
+   Item::Failed(Message,Cnf);
+}
+                                                                       /*}}}*/
+
 pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner,
                             string URI,string URIDesc,string ShortDesc,
                             string MetaIndexURI, string MetaIndexURIDesc,
@@ -360,8 +401,9 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner,
    DestFile = _config->FindDir("Dir::State::lists") + "partial/";
    DestFile += URItoFileName(URI);
 
-   // remove any partial downloaded sig-file. it may confuse proxies
-   // and is too small to warrant a partial download anyway
+   // remove any partial downloaded sig-file in partial/. 
+   // it may confuse proxies and is too small to warrant a 
+   // partial download anyway
    unlink(DestFile.c_str());
 
    // Create the item
@@ -428,17 +470,22 @@ void pkgAcqMetaSig::Done(string Message,unsigned long Size,string MD5,
                                                                        /*}}}*/
 void pkgAcqMetaSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
 {
+   string Final = _config->FindDir("Dir::State::lists") + URItoFileName(RealURI);
 
    // if we get a network error we fail gracefully
-   if(LookupTag(Message,"FailReason") == "Timeout" || 
-      LookupTag(Message,"FailReason") == "TmpResolveFailure" ||
-      LookupTag(Message,"FailReason") == "ConnectionRefused") {
+   if(Status == StatTransientNetworkError)
+   {
       Item::Failed(Message,Cnf);
+      // move the sigfile back on network failures (and re-authenticated?)
+      if(FileExists(DestFile))
+        Rename(DestFile,Final);
+
+      // set the status back to , Item::Failed likes to reset it
+      Status = pkgAcquire::Item::StatTransientNetworkError;
       return;
    }
 
    // Delete any existing sigfile when the acquire failed
-   string Final = _config->FindDir("Dir::State::lists") + URItoFileName(RealURI);
    unlink(Final.c_str());
 
    // queue a pkgAcqMetaIndex with no sigfile
@@ -761,6 +808,7 @@ void pkgAcqMetaIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
       }
 
       // gpgv method failed 
+      ReportMirrorFailure("GPGFailure");
       _error->Warning("GPG error: %s: %s",
                       Desc.Description.c_str(),
                       LookupTag(Message,"Message").c_str());