Pārlūkot izejas kodu

Havocs cancel patch
Author: jgg
Date: 1999-06-13 05:06:40 GMT
Havocs cancel patch

Arch Librarian 22 gadi atpakaļ
vecāks
revīzija
024d1123bf
5 mainītis faili ar 34 papildinājumiem un 18 dzēšanām
  1. 17 6
      apt-pkg/acquire.cc
  2. 6 3
      apt-pkg/acquire.h
  3. 5 3
      cmdline/acqprogress.cc
  4. 2 2
      cmdline/acqprogress.h
  5. 4 4
      cmdline/apt-get.cc

+ 17 - 6
apt-pkg/acquire.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: acquire.cc,v 1.35 1999/06/06 06:58:36 jgg Exp $
+// $Id: acquire.cc,v 1.36 1999/06/13 05:06:40 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Acquire - File Acquiration
    Acquire - File Acquiration
@@ -275,7 +275,7 @@ void pkgAcquire::RunFds(fd_set *RSet,fd_set *WSet)
 /* This runs the queues. It manages a select loop for all of the
 /* This runs the queues. It manages a select loop for all of the
    Worker tasks. The workers interact with the queues and items to
    Worker tasks. The workers interact with the queues and items to
    manage the actual fetch. */
    manage the actual fetch. */
-bool pkgAcquire::Run()
+pkgAcquire::RunResult pkgAcquire::Run()
 {
 {
    Running = true;
    Running = true;
    
    
@@ -285,6 +285,8 @@ bool pkgAcquire::Run()
    if (Log != 0)
    if (Log != 0)
       Log->Start();
       Log->Start();
    
    
+   bool WasCancelled = false;
+
    // Run till all things have been acquired
    // Run till all things have been acquired
    struct timeval tv;
    struct timeval tv;
    tv.tv_sec = 0;
    tv.tv_sec = 0;
@@ -321,8 +323,11 @@ bool pkgAcquire::Run()
 	 tv.tv_usec = 500000;
 	 tv.tv_usec = 500000;
 	 for (Worker *I = Workers; I != 0; I = I->NextAcquire)
 	 for (Worker *I = Workers; I != 0; I = I->NextAcquire)
 	    I->Pulse();
 	    I->Pulse();
-	 if (Log != 0)
-	    Log->Pulse(this);
+	 if (Log != 0 && Log->Pulse(this) == false)
+	 {
+	    WasCancelled = true;
+	    break;
+	 }
       }      
       }      
    }   
    }   
 
 
@@ -338,7 +343,11 @@ bool pkgAcquire::Run()
    for (Item **I = Items.begin(); I != Items.end(); I++)
    for (Item **I = Items.begin(); I != Items.end(); I++)
       (*I)->Finished();
       (*I)->Finished();
    
    
-   return !_error->PendingError();
+   if (_error->PendingError())
+      return Failed;
+   if (WasCancelled)
+      return Cancelled;
+   return Continue;
 }
 }
 									/*}}}*/
 									/*}}}*/
 // Acquire::Bump - Called when an item is dequeued			/*{{{*/
 // Acquire::Bump - Called when an item is dequeued			/*{{{*/
@@ -675,7 +684,7 @@ pkgAcquireStatus::pkgAcquireStatus()
 /* This computes some internal state variables for the derived classes to
 /* This computes some internal state variables for the derived classes to
    use. It generates the current downloaded bytes and total bytes to download
    use. It generates the current downloaded bytes and total bytes to download
    as well as the current CPS estimate. */
    as well as the current CPS estimate. */
-void pkgAcquireStatus::Pulse(pkgAcquire *Owner)
+bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
 {
 {
    TotalBytes = 0;
    TotalBytes = 0;
    CurrentBytes = 0;
    CurrentBytes = 0;
@@ -742,6 +751,8 @@ void pkgAcquireStatus::Pulse(pkgAcquire *Owner)
       ElapsedTime = (unsigned long)Delta;
       ElapsedTime = (unsigned long)Delta;
       Time = NewTime;
       Time = NewTime;
    }
    }
+
+   return true;
 }
 }
 									/*}}}*/
 									/*}}}*/
 // AcquireStatus::Start - Called when the download is started		/*{{{*/
 // AcquireStatus::Start - Called when the download is started		/*{{{*/

+ 6 - 3
apt-pkg/acquire.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: acquire.h,v 1.20 1999/03/27 03:02:39 jgg Exp $
+// $Id: acquire.h,v 1.21 1999/06/13 05:06:40 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Acquire - File Acquiration
    Acquire - File Acquiration
@@ -91,7 +91,10 @@ class pkgAcquire
    public:
    public:
 
 
    MethodConfig *GetConfig(string Access);
    MethodConfig *GetConfig(string Access);
-   bool Run();
+
+   enum RunResult {Continue,Failed,Cancelled};
+
+   RunResult Run();
 
 
    // Simple iteration mechanism
    // Simple iteration mechanism
    inline Worker *WorkersBegin() {return Workers;};
    inline Worker *WorkersBegin() {return Workers;};
@@ -259,7 +262,7 @@ class pkgAcquireStatus
    virtual void Fetch(pkgAcquire::ItemDesc &Itm) {};
    virtual void Fetch(pkgAcquire::ItemDesc &Itm) {};
    virtual void Done(pkgAcquire::ItemDesc &Itm) {};
    virtual void Done(pkgAcquire::ItemDesc &Itm) {};
    virtual void Fail(pkgAcquire::ItemDesc &Itm) {};
    virtual void Fail(pkgAcquire::ItemDesc &Itm) {};
-   virtual void Pulse(pkgAcquire *Owner);
+   virtual bool Pulse(pkgAcquire *Owner); // returns false on user cancel
    virtual void Start();
    virtual void Start();
    virtual void Stop();
    virtual void Stop();
    
    

+ 5 - 3
cmdline/acqprogress.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: acqprogress.cc,v 1.14 1999/06/06 05:52:37 jgg Exp $
+// $Id: acqprogress.cc,v 1.15 1999/06/13 05:06:40 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Acquire Progress - Command line progress meter 
    Acquire Progress - Command line progress meter 
@@ -132,10 +132,10 @@ void AcqTextStatus::Stop()
 /* This draws the current progress. Each line has an overall percent
 /* This draws the current progress. Each line has an overall percent
    meter and a per active item status meter along with an overall 
    meter and a per active item status meter along with an overall 
    bandwidth and ETA indicator. */
    bandwidth and ETA indicator. */
-void AcqTextStatus::Pulse(pkgAcquire *Owner)
+bool AcqTextStatus::Pulse(pkgAcquire *Owner)
 {
 {
    if (Quiet > 0)
    if (Quiet > 0)
-      return;
+      return true;
    
    
    pkgAcquireStatus::Pulse(Owner);
    pkgAcquireStatus::Pulse(Owner);
    
    
@@ -244,6 +244,8 @@ void AcqTextStatus::Pulse(pkgAcquire *Owner)
    BlankLine[strlen(Buffer)] = 0;
    BlankLine[strlen(Buffer)] = 0;
    
    
    Update = false;
    Update = false;
+
+   return true;
 }
 }
 									/*}}}*/
 									/*}}}*/
 // AcqTextStatus::MediaChange - Media need to be swapped		/*{{{*/
 // AcqTextStatus::MediaChange - Media need to be swapped		/*{{{*/

+ 2 - 2
cmdline/acqprogress.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: acqprogress.h,v 1.3 1998/12/04 21:16:53 jgg Exp $
+// $Id: acqprogress.h,v 1.4 1999/06/13 05:06:40 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Acquire Progress - Command line progress meter 
    Acquire Progress - Command line progress meter 
@@ -29,7 +29,7 @@ class AcqTextStatus : public pkgAcquireStatus
    virtual void Start();
    virtual void Start();
    virtual void Stop();
    virtual void Stop();
    
    
-   void Pulse(pkgAcquire *Owner);
+   bool Pulse(pkgAcquire *Owner);
 
 
    AcqTextStatus(unsigned int &ScreenWidth,unsigned int Quiet);
    AcqTextStatus(unsigned int &ScreenWidth,unsigned int Quiet);
 };
 };

+ 4 - 4
cmdline/apt-get.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: apt-get.cc,v 1.64 1999/06/06 05:52:37 jgg Exp $
+// $Id: apt-get.cc,v 1.65 1999/06/13 05:06:40 jgg Exp $
 /* ######################################################################
 /* ######################################################################
    
    
    apt-get - Cover for dpkg
    apt-get - Cover for dpkg
@@ -590,7 +590,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,bool Saftey =
    
    
    // Run it
    // Run it
    if (_config->FindB("APT::Get::No-Download",false) == false)
    if (_config->FindB("APT::Get::No-Download",false) == false)
-      if( Fetcher.Run() == false)
+      if( Fetcher.Run() == pkgAcquire::Failed)
 	 return false;
 	 return false;
 
 
    // Print out errors
    // Print out errors
@@ -679,7 +679,7 @@ bool DoUpdate(CommandLine &)
    }
    }
    
    
    // Run it
    // Run it
-   if (Fetcher.Run() == false)
+   if (Fetcher.Run() == pkgAcquire::Failed)
       return false;
       return false;
 
 
    // Clean out any old list files
    // Clean out any old list files
@@ -1217,7 +1217,7 @@ bool DoSource(CommandLine &CmdL)
    }
    }
    
    
    // Run it
    // Run it
-   if (Fetcher.Run() == false)
+   if (Fetcher.Run() == pkgAcquire::Failed)
       return false;
       return false;
 
 
    // Print error messages
    // Print error messages