// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: acquire-worker.cc,v 1.9 1998/11/01 05:27:33 jgg Exp $
+// $Id: acquire-worker.cc,v 1.12 1998/11/14 01:39:44 jgg Exp $
/* ######################################################################
Acquire Worker
#include <apt-pkg/fileutl.h>
#include <strutl.h>
+#include <sys/stat.h>
#include <unistd.h>
#include <signal.h>
#include <wait.h>
// Worker::Worker - Constructor for Queue startup /*{{{*/
// ---------------------------------------------------------------------
/* */
-pkgAcquire::Worker::Worker(Queue *Q,MethodConfig *Cnf)
+pkgAcquire::Worker::Worker(Queue *Q,MethodConfig *Cnf,
+ pkgAcquireStatus *Log) : Log(Log)
{
OwnerQ = Q;
Config = Cnf;
pkgAcquire::Queue::QItem *Itm = 0;
if (URI.empty() == false)
Itm = OwnerQ->FindItem(URI,this);
-
+
// Determine the message number and dispatch
switch (Number)
{
_error->Error("Method gave invalid 200 URI Start message");
break;
}
+
CurrentItem = Itm;
CurrentSize = 0;
TotalSize = atoi(LookupTag(Message,"Size","0").c_str());
+ Itm->Owner->Start(Message,atoi(LookupTag(Message,"Size","0").c_str()));
+ if (Log != 0)
+ Log->Fetch(*Itm);
+
break;
}
break;
}
+ pkgAcquire::Item *Owner = Itm->Owner;
+ pkgAcquire::ItemDesc Desc = *Itm;
OwnerQ->ItemDone(Itm);
- Itm->Owner->Done(Message,atoi(LookupTag(Message,"Size","0").c_str()),
+ Owner->Done(Message,atoi(LookupTag(Message,"Size","0").c_str()),
LookupTag(Message,"MD5-Hash"));
+ ItemDone();
+
+ // Log that we are done
+ if (Log != 0)
+ {
+ if (StringToBool(LookupTag(Message,"IMS-Hit"),false) == true ||
+ StringToBool(LookupTag(Message,"Alt-IMS-Hit"),false) == true)
+ Log->IMSHit(Desc);
+ else
+ Log->Done(Desc);
+ }
break;
}
break;
}
+ pkgAcquire::Item *Owner = Itm->Owner;
+ pkgAcquire::ItemDesc Desc = *Itm;
OwnerQ->ItemDone(Itm);
- Itm->Owner->Failed(Message);
+ Owner->Failed(Message);
+ ItemDone();
+
+ if (Log != 0)
+ Log->Fail(Desc);
+
break;
}
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);
// Some debug text
if (Debug == true)
return false;
}
/*}}}*/
+// Worker::Pulse - Called periodically /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+void pkgAcquire::Worker::Pulse()
+{
+ if (CurrentItem == 0)
+ return;
+
+
+ struct stat Buf;
+ if (stat(CurrentItem->Owner->DestFile.c_str(),&Buf) != 0)
+ return;
+ CurrentSize = Buf.st_size;
+}
+ /*}}}*/
+// Worker::ItemDone - Called when the current item is finished /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+void pkgAcquire::Worker::ItemDone()
+{
+ CurrentItem = 0;
+ CurrentSize = 0;
+ TotalSize = 0;
+ Status = string();
+}
+ /*}}}*/