// -*- mode: cpp; mode: fold -*-
// 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
/* This runs the queues. It manages a select loop for all of the
Worker tasks. The workers interact with the queues and items to
manage the actual fetch. */
-bool pkgAcquire::Run()
+pkgAcquire::RunResult pkgAcquire::Run()
{
Running = true;
if (Log != 0)
Log->Start();
+ bool WasCancelled = false;
+
// Run till all things have been acquired
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 500000;
for (Worker *I = Workers; I != 0; I = I->NextAcquire)
I->Pulse();
- if (Log != 0)
- Log->Pulse(this);
+ if (Log != 0 && Log->Pulse(this) == false)
+ {
+ WasCancelled = true;
+ break;
+ }
}
}
for (Item **I = Items.begin(); I != Items.end(); I++)
(*I)->Finished();
- return !_error->PendingError();
+ if (_error->PendingError())
+ return Failed;
+ if (WasCancelled)
+ return Cancelled;
+ return Continue;
}
/*}}}*/
// Acquire::Bump - Called when an item is dequeued /*{{{*/
/* This computes some internal state variables for the derived classes to
use. It generates the current downloaded bytes and total bytes to download
as well as the current CPS estimate. */
-void pkgAcquireStatus::Pulse(pkgAcquire *Owner)
+bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
{
TotalBytes = 0;
CurrentBytes = 0;
ElapsedTime = (unsigned long)Delta;
Time = NewTime;
}
+
+ return true;
}
/*}}}*/
// AcquireStatus::Start - Called when the download is started /*{{{*/
// -*- mode: cpp; mode: fold -*-
// 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
public:
MethodConfig *GetConfig(string Access);
- bool Run();
+
+ enum RunResult {Continue,Failed,Cancelled};
+
+ RunResult Run();
// Simple iteration mechanism
inline Worker *WorkersBegin() {return Workers;};
virtual void Fetch(pkgAcquire::ItemDesc &Itm) {};
virtual void Done(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 Stop();
// -*- mode: cpp; mode: fold -*-
// 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
/* This draws the current progress. Each line has an overall percent
meter and a per active item status meter along with an overall
bandwidth and ETA indicator. */
-void AcqTextStatus::Pulse(pkgAcquire *Owner)
+bool AcqTextStatus::Pulse(pkgAcquire *Owner)
{
if (Quiet > 0)
- return;
+ return true;
pkgAcquireStatus::Pulse(Owner);
BlankLine[strlen(Buffer)] = 0;
Update = false;
+
+ return true;
}
/*}}}*/
// AcqTextStatus::MediaChange - Media need to be swapped /*{{{*/
// -*- mode: cpp; mode: fold -*-
// 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
virtual void Start();
virtual void Stop();
- void Pulse(pkgAcquire *Owner);
+ bool Pulse(pkgAcquire *Owner);
AcqTextStatus(unsigned int &ScreenWidth,unsigned int Quiet);
};
// -*- mode: cpp; mode: fold -*-
// 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
// Run it
if (_config->FindB("APT::Get::No-Download",false) == false)
- if( Fetcher.Run() == false)
+ if( Fetcher.Run() == pkgAcquire::Failed)
return false;
// Print out errors
}
// Run it
- if (Fetcher.Run() == false)
+ if (Fetcher.Run() == pkgAcquire::Failed)
return false;
// Clean out any old list files
}
// Run it
- if (Fetcher.Run() == false)
+ if (Fetcher.Run() == pkgAcquire::Failed)
return false;
// Print error messages