Просмотр исходного кода

Minor Acquire cleanup
Author: jgg
Date: 1998-11-29 01:24:14 GMT
Minor Acquire cleanup

Arch Librarian лет назад: 22
Родитель
Сommit
a72ace2091
6 измененных файлов с 41 добавлено и 30 удалено
  1. 15 5
      apt-pkg/acquire-item.cc
  2. 14 11
      apt-pkg/acquire-method.cc
  3. 8 7
      apt-pkg/acquire-method.h
  4. 2 3
      apt-pkg/acquire-worker.cc
  5. 1 2
      apt-pkg/acquire.cc
  6. 1 2
      apt-pkg/acquire.h

+ 15 - 5
apt-pkg/acquire-item.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
-// $Id: acquire-item.cc,v 1.13 1998/11/22 03:20:30 jgg Exp $
+// $Id: acquire-item.cc,v 1.14 1998/11/29 01:24:14 jgg Exp $
 /* ######################################################################
 
    Acquire Item - Item to acquire
@@ -56,6 +56,16 @@ void pkgAcquire::Item::Failed(string Message)
    Status = StatIdle;
    if (QueueCounter <= 1)
    {
+      /* This indicates that the file is not available right now but might
+         be sometime later. If we do a retry cycle then this should be 
+	 retried */
+      if (StringToBool(LookupTag(Message,"Transient-Failure"),false) == true)
+      {
+	 Status = StatIdle;
+	 Owner->Dequeue(this);
+	 return;
+      }
+      
       ErrorText = LookupTag(Message,"Message");
       Status = StatError;
       Owner->Dequeue(this);
@@ -147,9 +157,9 @@ string pkgAcqIndex::Custom600Headers()
    
    struct stat Buf;
    if (stat(Final.c_str(),&Buf) != 0)
-      return string();
+      return "\nIndex-File: true";
    
-   return "\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
+   return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
 }
 									/*}}}*/
 // AcqIndex::Done - Finished a fetch					/*{{{*/
@@ -267,9 +277,9 @@ string pkgAcqIndexRel::Custom600Headers()
    
    struct stat Buf;
    if (stat(Final.c_str(),&Buf) != 0)
-      return string();
+      return "\nIndex-File: true";
    
-   return "\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
+   return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
 }
 									/*}}}*/
 // AcqIndexRel::Done - Item downloaded OK				/*{{{*/

+ 14 - 11
apt-pkg/acquire-method.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
-// $Id: acquire-method.cc,v 1.8 1998/11/14 01:39:41 jgg Exp $
+// $Id: acquire-method.cc,v 1.9 1998/11/29 01:24:15 jgg Exp $
 /* ######################################################################
 
    Acquire Method
@@ -33,9 +33,6 @@ pkgAcqMethod::pkgAcqMethod(const char *Ver,unsigned long Flags)
    if ((Flags & SingleInstance) == SingleInstance)
       strcat(End,"Single-Instance: true\n");
    
-   if ((Flags & PreScan) == PreScan)
-      strcat(End,"Pre-Scan: true\n");
-   
    if ((Flags & Pipeline) == Pipeline)
       strcat(End,"Pipeline: true\n");
    
@@ -57,26 +54,26 @@ pkgAcqMethod::pkgAcqMethod(const char *Ver,unsigned long Flags)
 // AcqMethod::Fail - A fetch has failed					/*{{{*/
 // ---------------------------------------------------------------------
 /* */
-void pkgAcqMethod::Fail()
+void pkgAcqMethod::Fail(bool Transient)
 {
    string Err = "Undetermined Error";
    if (_error->empty() == false)
       _error->PopMessage(Err);   
    _error->Discard();
-   Fail(Err);
+   Fail(Err,Transient);
 }
 									/*}}}*/
 // AcqMethod::Fail - A fetch has failed					/*{{{*/
 // ---------------------------------------------------------------------
 /* */
-void pkgAcqMethod::Fail(string Err)
+void pkgAcqMethod::Fail(string Err,bool Transient)
 {   
    char S[1024];
    if (Queue != 0)
    {
       snprintf(S,sizeof(S),"400 URI Failure\nURI: %s\n"
-	       "Message: %s\n\n",Queue->Uri.c_str(),Err.c_str());
-      
+	       "Message: %s\n",Queue->Uri.c_str(),Err.c_str());
+
       // Dequeue
       FetchItem *Tmp = Queue;
       Queue = Queue->Next;
@@ -84,8 +81,14 @@ void pkgAcqMethod::Fail(string Err)
    }
    else
       snprintf(S,sizeof(S),"400 URI Failure\nURI: <UNKNOWN>\n"
-	       "Message: %s\n\n",Err.c_str());
+	       "Message: %s\n",Err.c_str());
       
+   // Set the transient flag 
+   if (Transient == true)
+      strcat(S,"Transient-Failure: true\n\n");
+   else
+      strcat(S,"\n");
+   
    if (write(STDOUT_FILENO,S,strlen(S)) != (signed)strlen(S))
       exit(100);
 }
@@ -265,7 +268,7 @@ int pkgAcqMethod::Run(bool Single)
 	    Tmp->DestFile = LookupTag(Message,"FileName");
 	    if (StrToTime(LookupTag(Message,"Last-Modified"),Tmp->LastModified) == false)
 	       Tmp->LastModified = 0;
-	    
+	    Tmp->IndexFile = StringToBool(LookupTag(Message,"Index-File"),false);
 	    Tmp->Next = 0;
 	    
 	    // Append it to the list

+ 8 - 7
apt-pkg/acquire-method.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
-// $Id: acquire-method.h,v 1.3 1998/11/14 01:39:43 jgg Exp $
+// $Id: acquire-method.h,v 1.4 1998/11/29 01:24:16 jgg Exp $
 /* ######################################################################
 
    Acquire Method - Method helper class + functions
@@ -31,6 +31,7 @@ class pkgAcqMethod
       string Uri;
       string DestFile;
       time_t LastModified;
+      bool IndexFile;
    };
    
    struct FetchResult
@@ -53,16 +54,16 @@ class pkgAcqMethod
    virtual bool Fetch(FetchItem *Item) {return true;};
    
    // Outgoing messages
-   void Fail();
-   void Fail(string Why);
+   void Fail(bool Transient = false);
+   void Fail(string Why, bool Transient = false);
    void URIStart(FetchResult &Res);
    void URIDone(FetchResult &Res,FetchResult *Alt = 0);
 		 
    public:
-   
-   enum CnfFlags {SingleInstance = (1<<0), PreScan = (1<<1), 
-                  Pipeline = (1<<2), SendConfig = (1<<3), 
-                  LocalOnly = (1<<4)};
+
+   enum CnfFlags {SingleInstance = (1<<0),
+                  Pipeline = (1<<1), SendConfig = (1<<2),
+                  LocalOnly = (1<<3)};
 
    void Log(const char *Format,...);
    void Status(const char *Format,...);

+ 2 - 3
apt-pkg/acquire-worker.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
-// $Id: acquire-worker.cc,v 1.12 1998/11/14 01:39:44 jgg Exp $
+// $Id: acquire-worker.cc,v 1.13 1998/11/29 01:24:18 jgg Exp $
 /* ######################################################################
 
    Acquire Worker 
@@ -304,7 +304,6 @@ bool pkgAcquire::Worker::Capabilities(string Message)
    
    Config->Version = LookupTag(Message,"Version");
    Config->SingleInstance = StringToBool(LookupTag(Message,"Single-Instance"),false);
-   Config->PreScan = StringToBool(LookupTag(Message,"Pre-Scan"),false);
    Config->Pipeline = StringToBool(LookupTag(Message,"Pipeline"),false);
    Config->SendConfig = StringToBool(LookupTag(Message,"Send-Config"),false);
    Config->LocalOnly = StringToBool(LookupTag(Message,"Local-Only"),false);
@@ -314,7 +313,7 @@ bool pkgAcquire::Worker::Capabilities(string Message)
    {
       clog << "Configured access method " << Config->Access << endl;
       clog << "Version:" << Config->Version << " SingleInstance:" <<
-	 Config->SingleInstance << " PreScan: " << Config->PreScan <<
+	 Config->SingleInstance << 
 	 " Pipeline:" << Config->Pipeline << " SendConfig:" << 
 	 Config->SendConfig << endl;
    }

+ 1 - 2
apt-pkg/acquire.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
-// $Id: acquire.cc,v 1.18 1998/11/23 07:32:19 jgg Exp $
+// $Id: acquire.cc,v 1.19 1998/11/29 01:24:19 jgg Exp $
 /* ######################################################################
 
    Acquire - File Acquiration
@@ -420,7 +420,6 @@ unsigned long pkgAcquire::FetchNeeded()
 pkgAcquire::MethodConfig::MethodConfig()
 {
    SingleInstance = false;
-   PreScan = false;
    Pipeline = false;
    SendConfig = false;
    LocalOnly = false;

+ 1 - 2
apt-pkg/acquire.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
-// $Id: acquire.h,v 1.14 1998/11/23 07:32:20 jgg Exp $
+// $Id: acquire.h,v 1.15 1998/11/29 01:24:20 jgg Exp $
 /* ######################################################################
 
    Acquire - File Acquiration
@@ -179,7 +179,6 @@ struct pkgAcquire::MethodConfig
 
    string Version;
    bool SingleInstance;
-   bool PreScan;
    bool Pipeline;
    bool SendConfig;
    bool LocalOnly;