acquire-worker.cc 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: acquire-worker.cc,v 1.34 2001/05/22 04:42:54 jgg Exp $
  4. /* ######################################################################
  5. Acquire Worker
  6. The worker process can startup either as a Configuration prober
  7. or as a queue runner. As a configuration prober it only reads the
  8. configuration message and
  9. ##################################################################### */
  10. /*}}}*/
  11. // Include Files /*{{{*/
  12. #include <config.h>
  13. #include <apt-pkg/acquire.h>
  14. #include <apt-pkg/acquire-worker.h>
  15. #include <apt-pkg/acquire-item.h>
  16. #include <apt-pkg/configuration.h>
  17. #include <apt-pkg/error.h>
  18. #include <apt-pkg/fileutl.h>
  19. #include <apt-pkg/strutl.h>
  20. #include <apt-pkg/hashes.h>
  21. #include <string>
  22. #include <vector>
  23. #include <iostream>
  24. #include <sstream>
  25. #include <sys/stat.h>
  26. #include <stdlib.h>
  27. #include <unistd.h>
  28. #include <signal.h>
  29. #include <stdio.h>
  30. #include <errno.h>
  31. #include <sys/types.h>
  32. #include <pwd.h>
  33. #include <grp.h>
  34. #include <apti18n.h>
  35. /*}}}*/
  36. using namespace std;
  37. // Worker::Worker - Constructor for Queue startup /*{{{*/
  38. // ---------------------------------------------------------------------
  39. /* */
  40. pkgAcquire::Worker::Worker(Queue *Q,MethodConfig *Cnf,
  41. pkgAcquireStatus *Log) : Log(Log)
  42. {
  43. OwnerQ = Q;
  44. Config = Cnf;
  45. Access = Cnf->Access;
  46. CurrentItem = 0;
  47. TotalSize = 0;
  48. CurrentSize = 0;
  49. Construct();
  50. }
  51. /*}}}*/
  52. // Worker::Worker - Constructor for method config startup /*{{{*/
  53. // ---------------------------------------------------------------------
  54. /* */
  55. pkgAcquire::Worker::Worker(MethodConfig *Cnf)
  56. {
  57. OwnerQ = 0;
  58. Config = Cnf;
  59. Access = Cnf->Access;
  60. CurrentItem = 0;
  61. TotalSize = 0;
  62. CurrentSize = 0;
  63. Construct();
  64. }
  65. /*}}}*/
  66. // Worker::Construct - Constructor helper /*{{{*/
  67. // ---------------------------------------------------------------------
  68. /* */
  69. void pkgAcquire::Worker::Construct()
  70. {
  71. NextQueue = 0;
  72. NextAcquire = 0;
  73. Process = -1;
  74. InFd = -1;
  75. OutFd = -1;
  76. OutReady = false;
  77. InReady = false;
  78. Debug = _config->FindB("Debug::pkgAcquire::Worker",false);
  79. }
  80. /*}}}*/
  81. // Worker::~Worker - Destructor /*{{{*/
  82. // ---------------------------------------------------------------------
  83. /* */
  84. pkgAcquire::Worker::~Worker()
  85. {
  86. close(InFd);
  87. close(OutFd);
  88. if (Process > 0)
  89. {
  90. /* Closing of stdin is the signal to exit and die when the process
  91. indicates it needs cleanup */
  92. if (Config->NeedsCleanup == false)
  93. kill(Process,SIGINT);
  94. ExecWait(Process,Access.c_str(),true);
  95. }
  96. }
  97. /*}}}*/
  98. // Worker::Start - Start the worker process /*{{{*/
  99. // ---------------------------------------------------------------------
  100. /* This forks the method and inits the communication channel */
  101. bool pkgAcquire::Worker::Start()
  102. {
  103. // Get the method path
  104. string Method = _config->FindDir("Dir::Bin::Methods") + Access;
  105. if (FileExists(Method) == false)
  106. {
  107. _error->Error(_("The method driver %s could not be found."),Method.c_str());
  108. if (Access == "https")
  109. _error->Notice(_("Is the package %s installed?"), "apt-transport-https");
  110. return false;
  111. }
  112. if (Debug == true)
  113. clog << "Starting method '" << Method << '\'' << endl;
  114. // Create the pipes
  115. int Pipes[4] = {-1,-1,-1,-1};
  116. if (pipe(Pipes) != 0 || pipe(Pipes+2) != 0)
  117. {
  118. _error->Errno("pipe","Failed to create IPC pipe to subprocess");
  119. for (int I = 0; I != 4; I++)
  120. close(Pipes[I]);
  121. return false;
  122. }
  123. for (int I = 0; I != 4; I++)
  124. SetCloseExec(Pipes[I],true);
  125. // Fork off the process
  126. Process = ExecFork();
  127. if (Process == 0)
  128. {
  129. // Setup the FDs
  130. dup2(Pipes[1],STDOUT_FILENO);
  131. dup2(Pipes[2],STDIN_FILENO);
  132. SetCloseExec(STDOUT_FILENO,false);
  133. SetCloseExec(STDIN_FILENO,false);
  134. SetCloseExec(STDERR_FILENO,false);
  135. const char *Args[2];
  136. Args[0] = Method.c_str();
  137. Args[1] = 0;
  138. execv(Args[0],(char **)Args);
  139. cerr << "Failed to exec method " << Args[0] << endl;
  140. _exit(100);
  141. }
  142. // Fix up our FDs
  143. InFd = Pipes[0];
  144. OutFd = Pipes[3];
  145. SetNonBlock(Pipes[0],true);
  146. SetNonBlock(Pipes[3],true);
  147. close(Pipes[1]);
  148. close(Pipes[2]);
  149. OutReady = false;
  150. InReady = true;
  151. // Read the configuration data
  152. if (WaitFd(InFd) == false ||
  153. ReadMessages() == false)
  154. return _error->Error(_("Method %s did not start correctly"),Method.c_str());
  155. RunMessages();
  156. if (OwnerQ != 0)
  157. SendConfiguration();
  158. return true;
  159. }
  160. /*}}}*/
  161. // Worker::ReadMessages - Read all pending messages into the list /*{{{*/
  162. // ---------------------------------------------------------------------
  163. /* */
  164. bool pkgAcquire::Worker::ReadMessages()
  165. {
  166. if (::ReadMessages(InFd,MessageQueue) == false)
  167. return MethodFailure();
  168. return true;
  169. }
  170. /*}}}*/
  171. // Worker::RunMessage - Empty the message queue /*{{{*/
  172. // ---------------------------------------------------------------------
  173. /* This takes the messages from the message queue and runs them through
  174. the parsers in order. */
  175. bool pkgAcquire::Worker::RunMessages()
  176. {
  177. while (MessageQueue.empty() == false)
  178. {
  179. string Message = MessageQueue.front();
  180. MessageQueue.erase(MessageQueue.begin());
  181. if (Debug == true)
  182. clog << " <- " << Access << ':' << QuoteString(Message,"\n") << endl;
  183. // Fetch the message number
  184. char *End;
  185. int Number = strtol(Message.c_str(),&End,10);
  186. if (End == Message.c_str())
  187. return _error->Error("Invalid message from method %s: %s",Access.c_str(),Message.c_str());
  188. string URI = LookupTag(Message,"URI");
  189. pkgAcquire::Queue::QItem *Itm = 0;
  190. if (URI.empty() == false)
  191. Itm = OwnerQ->FindItem(URI,this);
  192. // update used mirror
  193. string UsedMirror = LookupTag(Message,"UsedMirror", "");
  194. if (!UsedMirror.empty() &&
  195. Itm &&
  196. Itm->Description.find(" ") != string::npos)
  197. {
  198. Itm->Description.replace(0, Itm->Description.find(" "), UsedMirror);
  199. // FIXME: will we need this as well?
  200. //Itm->ShortDesc = UsedMirror;
  201. }
  202. // Determine the message number and dispatch
  203. switch (Number)
  204. {
  205. // 100 Capabilities
  206. case 100:
  207. if (Capabilities(Message) == false)
  208. return _error->Error("Unable to process Capabilities message from %s",Access.c_str());
  209. break;
  210. // 101 Log
  211. case 101:
  212. if (Debug == true)
  213. clog << " <- (log) " << LookupTag(Message,"Message") << endl;
  214. break;
  215. // 102 Status
  216. case 102:
  217. Status = LookupTag(Message,"Message");
  218. break;
  219. // 103 Redirect
  220. case 103:
  221. {
  222. if (Itm == 0)
  223. {
  224. _error->Error("Method gave invalid 103 Redirect message");
  225. break;
  226. }
  227. string NewURI = LookupTag(Message,"New-URI",URI.c_str());
  228. Itm->URI = NewURI;
  229. ItemDone();
  230. pkgAcquire::Item *Owner = Itm->Owner;
  231. pkgAcquire::ItemDesc Desc = *Itm;
  232. // Change the status so that it can be dequeued
  233. Owner->Status = pkgAcquire::Item::StatIdle;
  234. // Mark the item as done (taking care of all queues)
  235. // and then put it in the main queue again
  236. OwnerQ->ItemDone(Itm);
  237. OwnerQ->Owner->Enqueue(Desc);
  238. if (Log != 0)
  239. Log->Done(Desc);
  240. break;
  241. }
  242. // 200 URI Start
  243. case 200:
  244. {
  245. if (Itm == 0)
  246. {
  247. _error->Error("Method gave invalid 200 URI Start message");
  248. break;
  249. }
  250. CurrentItem = Itm;
  251. CurrentSize = 0;
  252. TotalSize = strtoull(LookupTag(Message,"Size","0").c_str(), NULL, 10);
  253. ResumePoint = strtoull(LookupTag(Message,"Resume-Point","0").c_str(), NULL, 10);
  254. Itm->Owner->Start(Message, TotalSize);
  255. // Display update before completion
  256. if (Log != 0 && Log->MorePulses == true)
  257. Log->Pulse(Itm->Owner->GetOwner());
  258. if (Log != 0)
  259. Log->Fetch(*Itm);
  260. break;
  261. }
  262. // 201 URI Done
  263. case 201:
  264. {
  265. if (Itm == 0)
  266. {
  267. _error->Error("Method gave invalid 201 URI Done message");
  268. break;
  269. }
  270. pkgAcquire::Item *Owner = Itm->Owner;
  271. pkgAcquire::ItemDesc Desc = *Itm;
  272. if (RealFileExists(Owner->DestFile))
  273. ChangeOwnerAndPermissionOfFile("201::URIDone", Owner->DestFile.c_str(), "root", "root", 0644);
  274. // Display update before completion
  275. if (Log != 0 && Log->MorePulses == true)
  276. Log->Pulse(Owner->GetOwner());
  277. OwnerQ->ItemDone(Itm);
  278. HashStringList const ExpectedHashes = Owner->GetExpectedHashes();
  279. // see if we got hashes to verify
  280. HashStringList ReceivedHashes;
  281. for (char const * const * type = HashString::SupportedHashes(); *type != NULL; ++type)
  282. {
  283. std::string const tagname = std::string(*type) + "-Hash";
  284. std::string const hashsum = LookupTag(Message, tagname.c_str());
  285. if (hashsum.empty() == false)
  286. ReceivedHashes.push_back(HashString(*type, hashsum));
  287. }
  288. // not all methods always sent Hashes our way
  289. if (ExpectedHashes.usable() == true && ReceivedHashes.usable() == false)
  290. {
  291. std::string const filename = LookupTag(Message, "Filename", Owner->DestFile.c_str());
  292. if (filename.empty() == false && RealFileExists(filename))
  293. {
  294. Hashes calc(ExpectedHashes);
  295. FileFd file(filename, FileFd::ReadOnly, FileFd::None);
  296. calc.AddFD(file);
  297. ReceivedHashes = calc.GetHashStringList();
  298. }
  299. }
  300. if(_config->FindB("Debug::pkgAcquire::Auth", false) == true)
  301. {
  302. std::clog << "201 URI Done: " << Owner->DescURI() << endl
  303. << "ReceivedHash:" << endl;
  304. for (HashStringList::const_iterator hs = ReceivedHashes.begin(); hs != ReceivedHashes.end(); ++hs)
  305. std::clog << "\t- " << hs->toStr() << std::endl;
  306. std::clog << "ExpectedHash:" << endl;
  307. for (HashStringList::const_iterator hs = ExpectedHashes.begin(); hs != ExpectedHashes.end(); ++hs)
  308. std::clog << "\t- " << hs->toStr() << std::endl;
  309. std::clog << endl;
  310. }
  311. // decide if what we got is what we expected
  312. bool consideredOkay = false;
  313. bool const isIMSHit = StringToBool(LookupTag(Message,"IMS-Hit"),false) ||
  314. StringToBool(LookupTag(Message,"Alt-IMS-Hit"),false);
  315. if (ExpectedHashes.usable())
  316. {
  317. if (ReceivedHashes.usable() == false)
  318. {
  319. /* IMS-Hits can't be checked here as we will have uncompressed file,
  320. but the hashes for the compressed file. What we have was good through
  321. so all we have to ensure later is that we are not stalled. */
  322. consideredOkay = isIMSHit;
  323. }
  324. else if (ReceivedHashes == ExpectedHashes)
  325. consideredOkay = true;
  326. else
  327. consideredOkay = false;
  328. }
  329. else if (Owner->HashesRequired() == true)
  330. consideredOkay = false;
  331. else
  332. consideredOkay = true;
  333. if (consideredOkay == true)
  334. {
  335. Owner->Done(Message, ReceivedHashes, Config);
  336. ItemDone();
  337. // Log that we are done
  338. if (Log != 0)
  339. {
  340. if (isIMSHit)
  341. {
  342. /* Hide 'hits' for local only sources - we also manage to
  343. hide gets */
  344. if (Config->LocalOnly == false)
  345. Log->IMSHit(Desc);
  346. }
  347. else
  348. Log->Done(Desc);
  349. }
  350. }
  351. else
  352. {
  353. Owner->Status = pkgAcquire::Item::StatAuthError;
  354. Owner->Failed(Message,Config);
  355. ItemDone();
  356. if (Log != 0)
  357. Log->Fail(Desc);
  358. }
  359. break;
  360. }
  361. // 400 URI Failure
  362. case 400:
  363. {
  364. if (Itm == 0)
  365. {
  366. std::string const msg = LookupTag(Message,"Message");
  367. _error->Error("Method gave invalid 400 URI Failure message: %s", msg.c_str());
  368. break;
  369. }
  370. // Display update before completion
  371. if (Log != 0 && Log->MorePulses == true)
  372. Log->Pulse(Itm->Owner->GetOwner());
  373. pkgAcquire::Item *Owner = Itm->Owner;
  374. pkgAcquire::ItemDesc Desc = *Itm;
  375. if (RealFileExists(Owner->DestFile))
  376. ChangeOwnerAndPermissionOfFile("400::URIFailure", Owner->DestFile.c_str(), "root", "root", 0644);
  377. OwnerQ->ItemDone(Itm);
  378. // set some status
  379. if(LookupTag(Message,"FailReason") == "Timeout" ||
  380. LookupTag(Message,"FailReason") == "TmpResolveFailure" ||
  381. LookupTag(Message,"FailReason") == "ResolveFailure" ||
  382. LookupTag(Message,"FailReason") == "ConnectionRefused")
  383. Owner->Status = pkgAcquire::Item::StatTransientNetworkError;
  384. Owner->Failed(Message,Config);
  385. ItemDone();
  386. if (Log != 0)
  387. Log->Fail(Desc);
  388. break;
  389. }
  390. // 401 General Failure
  391. case 401:
  392. _error->Error("Method %s General failure: %s",Access.c_str(),LookupTag(Message,"Message").c_str());
  393. break;
  394. // 403 Media Change
  395. case 403:
  396. MediaChange(Message);
  397. break;
  398. }
  399. }
  400. return true;
  401. }
  402. /*}}}*/
  403. // Worker::Capabilities - 100 Capabilities handler /*{{{*/
  404. // ---------------------------------------------------------------------
  405. /* This parses the capabilities message and dumps it into the configuration
  406. structure. */
  407. bool pkgAcquire::Worker::Capabilities(string Message)
  408. {
  409. if (Config == 0)
  410. return true;
  411. Config->Version = LookupTag(Message,"Version");
  412. Config->SingleInstance = StringToBool(LookupTag(Message,"Single-Instance"),false);
  413. Config->Pipeline = StringToBool(LookupTag(Message,"Pipeline"),false);
  414. Config->SendConfig = StringToBool(LookupTag(Message,"Send-Config"),false);
  415. Config->LocalOnly = StringToBool(LookupTag(Message,"Local-Only"),false);
  416. Config->NeedsCleanup = StringToBool(LookupTag(Message,"Needs-Cleanup"),false);
  417. Config->Removable = StringToBool(LookupTag(Message,"Removable"),false);
  418. // Some debug text
  419. if (Debug == true)
  420. {
  421. clog << "Configured access method " << Config->Access << endl;
  422. clog << "Version:" << Config->Version <<
  423. " SingleInstance:" << Config->SingleInstance <<
  424. " Pipeline:" << Config->Pipeline <<
  425. " SendConfig:" << Config->SendConfig <<
  426. " LocalOnly: " << Config->LocalOnly <<
  427. " NeedsCleanup: " << Config->NeedsCleanup <<
  428. " Removable: " << Config->Removable << endl;
  429. }
  430. return true;
  431. }
  432. /*}}}*/
  433. // Worker::MediaChange - Request a media change /*{{{*/
  434. // ---------------------------------------------------------------------
  435. /* */
  436. bool pkgAcquire::Worker::MediaChange(string Message)
  437. {
  438. int status_fd = _config->FindI("APT::Status-Fd",-1);
  439. if(status_fd > 0)
  440. {
  441. string Media = LookupTag(Message,"Media");
  442. string Drive = LookupTag(Message,"Drive");
  443. ostringstream msg,status;
  444. ioprintf(msg,_("Please insert the disc labeled: "
  445. "'%s' "
  446. "in the drive '%s' and press enter."),
  447. Media.c_str(),Drive.c_str());
  448. status << "media-change: " // message
  449. << Media << ":" // media
  450. << Drive << ":" // drive
  451. << msg.str() // l10n message
  452. << endl;
  453. std::string const dlstatus = status.str();
  454. FileFd::Write(status_fd, dlstatus.c_str(), dlstatus.size());
  455. }
  456. if (Log == 0 || Log->MediaChange(LookupTag(Message,"Media"),
  457. LookupTag(Message,"Drive")) == false)
  458. {
  459. char S[300];
  460. snprintf(S,sizeof(S),"603 Media Changed\nFailed: true\n\n");
  461. if (Debug == true)
  462. clog << " -> " << Access << ':' << QuoteString(S,"\n") << endl;
  463. OutQueue += S;
  464. OutReady = true;
  465. return true;
  466. }
  467. char S[300];
  468. snprintf(S,sizeof(S),"603 Media Changed\n\n");
  469. if (Debug == true)
  470. clog << " -> " << Access << ':' << QuoteString(S,"\n") << endl;
  471. OutQueue += S;
  472. OutReady = true;
  473. return true;
  474. }
  475. /*}}}*/
  476. // Worker::SendConfiguration - Send the config to the method /*{{{*/
  477. // ---------------------------------------------------------------------
  478. /* */
  479. bool pkgAcquire::Worker::SendConfiguration()
  480. {
  481. if (Config->SendConfig == false)
  482. return true;
  483. if (OutFd == -1)
  484. return false;
  485. /* Write out all of the configuration directives by walking the
  486. configuration tree */
  487. std::ostringstream Message;
  488. Message << "601 Configuration\n";
  489. _config->Dump(Message, NULL, "Config-Item: %F=%V\n", false);
  490. Message << '\n';
  491. if (Debug == true)
  492. clog << " -> " << Access << ':' << QuoteString(Message.str(),"\n") << endl;
  493. OutQueue += Message.str();
  494. OutReady = true;
  495. return true;
  496. }
  497. /*}}}*/
  498. // Worker::QueueItem - Add an item to the outbound queue /*{{{*/
  499. // ---------------------------------------------------------------------
  500. /* Send a URI Acquire message to the method */
  501. bool pkgAcquire::Worker::QueueItem(pkgAcquire::Queue::QItem *Item)
  502. {
  503. if (OutFd == -1)
  504. return false;
  505. string Message = "600 URI Acquire\n";
  506. Message.reserve(300);
  507. Message += "URI: " + Item->URI;
  508. Message += "\nFilename: " + Item->Owner->DestFile;
  509. HashStringList const hsl = Item->Owner->GetExpectedHashes();
  510. for (HashStringList::const_iterator hs = hsl.begin(); hs != hsl.end(); ++hs)
  511. Message += "\nExpected-" + hs->HashType() + ": " + hs->HashValue();
  512. if(Item->Owner->FileSize > 0)
  513. {
  514. string MaximumSize;
  515. strprintf(MaximumSize, "%llu", Item->Owner->FileSize);
  516. Message += "\nMaximum-Size: " + MaximumSize;
  517. }
  518. Message += Item->Owner->Custom600Headers();
  519. Message += "\n\n";
  520. if (RealFileExists(Item->Owner->DestFile))
  521. {
  522. std::string SandboxUser = _config->Find("APT::Sandbox::User");
  523. ChangeOwnerAndPermissionOfFile("Item::QueueURI", Item->Owner->DestFile.c_str(),
  524. SandboxUser.c_str(), "root", 0600);
  525. }
  526. if (Debug == true)
  527. clog << " -> " << Access << ':' << QuoteString(Message,"\n") << endl;
  528. OutQueue += Message;
  529. OutReady = true;
  530. return true;
  531. }
  532. /*}}}*/
  533. // Worker::OutFdRead - Out bound FD is ready /*{{{*/
  534. // ---------------------------------------------------------------------
  535. /* */
  536. bool pkgAcquire::Worker::OutFdReady()
  537. {
  538. int Res;
  539. do
  540. {
  541. Res = write(OutFd,OutQueue.c_str(),OutQueue.length());
  542. }
  543. while (Res < 0 && errno == EINTR);
  544. if (Res <= 0)
  545. return MethodFailure();
  546. OutQueue.erase(0,Res);
  547. if (OutQueue.empty() == true)
  548. OutReady = false;
  549. return true;
  550. }
  551. /*}}}*/
  552. // Worker::InFdRead - In bound FD is ready /*{{{*/
  553. // ---------------------------------------------------------------------
  554. /* */
  555. bool pkgAcquire::Worker::InFdReady()
  556. {
  557. if (ReadMessages() == false)
  558. return false;
  559. RunMessages();
  560. return true;
  561. }
  562. /*}}}*/
  563. // Worker::MethodFailure - Called when the method fails /*{{{*/
  564. // ---------------------------------------------------------------------
  565. /* This is called when the method is believed to have failed, probably because
  566. read returned -1. */
  567. bool pkgAcquire::Worker::MethodFailure()
  568. {
  569. _error->Error("Method %s has died unexpectedly!",Access.c_str());
  570. // do not reap the child here to show meaningfull error to the user
  571. ExecWait(Process,Access.c_str(),false);
  572. Process = -1;
  573. close(InFd);
  574. close(OutFd);
  575. InFd = -1;
  576. OutFd = -1;
  577. OutReady = false;
  578. InReady = false;
  579. OutQueue = string();
  580. MessageQueue.erase(MessageQueue.begin(),MessageQueue.end());
  581. return false;
  582. }
  583. /*}}}*/
  584. // Worker::Pulse - Called periodically /*{{{*/
  585. // ---------------------------------------------------------------------
  586. /* */
  587. void pkgAcquire::Worker::Pulse()
  588. {
  589. if (CurrentItem == 0)
  590. return;
  591. struct stat Buf;
  592. if (stat(CurrentItem->Owner->DestFile.c_str(),&Buf) != 0)
  593. return;
  594. CurrentSize = Buf.st_size;
  595. }
  596. /*}}}*/
  597. // Worker::ItemDone - Called when the current item is finished /*{{{*/
  598. // ---------------------------------------------------------------------
  599. /* */
  600. void pkgAcquire::Worker::ItemDone()
  601. {
  602. CurrentItem = 0;
  603. CurrentSize = 0;
  604. TotalSize = 0;
  605. Status = string();
  606. }
  607. /*}}}*/