acquire-item.cc 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: acquire-item.cc,v 1.40 1999/10/31 06:32:27 jgg Exp $
  4. /* ######################################################################
  5. Acquire Item - Item to acquire
  6. Each item can download to exactly one file at a time. This means you
  7. cannot create an item that fetches two uri's to two files at the same
  8. time. The pkgAcqIndex class creates a second class upon instantiation
  9. to fetch the other index files because of this.
  10. ##################################################################### */
  11. /*}}}*/
  12. // Include Files /*{{{*/
  13. #ifdef __GNUG__
  14. #pragma implementation "apt-pkg/acquire-item.h"
  15. #endif
  16. #include <apt-pkg/acquire-item.h>
  17. #include <apt-pkg/configuration.h>
  18. #include <apt-pkg/error.h>
  19. #include <apt-pkg/strutl.h>
  20. #include <apt-pkg/fileutl.h>
  21. #include <sys/stat.h>
  22. #include <unistd.h>
  23. #include <errno.h>
  24. #include <string.h>
  25. #include <stdio.h>
  26. /*}}}*/
  27. // Acquire::Item::Item - Constructor /*{{{*/
  28. // ---------------------------------------------------------------------
  29. /* */
  30. pkgAcquire::Item::Item(pkgAcquire *Owner) : Owner(Owner), FileSize(0),
  31. PartialSize(0), Mode(0), ID(0), Complete(false),
  32. Local(false), QueueCounter(0)
  33. {
  34. Owner->Add(this);
  35. Status = StatIdle;
  36. }
  37. /*}}}*/
  38. // Acquire::Item::~Item - Destructor /*{{{*/
  39. // ---------------------------------------------------------------------
  40. /* */
  41. pkgAcquire::Item::~Item()
  42. {
  43. Owner->Remove(this);
  44. }
  45. /*}}}*/
  46. // Acquire::Item::Failed - Item failed to download /*{{{*/
  47. // ---------------------------------------------------------------------
  48. /* We return to an idle state if there are still other queues that could
  49. fetch this object */
  50. void pkgAcquire::Item::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
  51. {
  52. Status = StatIdle;
  53. ErrorText = LookupTag(Message,"Message");
  54. if (QueueCounter <= 1)
  55. {
  56. /* This indicates that the file is not available right now but might
  57. be sometime later. If we do a retry cycle then this should be
  58. retried [CDROMs] */
  59. if (Cnf->LocalOnly == true &&
  60. StringToBool(LookupTag(Message,"Transient-Failure"),false) == true)
  61. {
  62. Status = StatIdle;
  63. Dequeue();
  64. return;
  65. }
  66. Status = StatError;
  67. Dequeue();
  68. }
  69. }
  70. /*}}}*/
  71. // Acquire::Item::Start - Item has begun to download /*{{{*/
  72. // ---------------------------------------------------------------------
  73. /* Stash status and the file size. Note that setting Complete means
  74. sub-phases of the acquire process such as decompresion are operating */
  75. void pkgAcquire::Item::Start(string /*Message*/,unsigned long Size)
  76. {
  77. Status = StatFetching;
  78. if (FileSize == 0 && Complete == false)
  79. FileSize = Size;
  80. }
  81. /*}}}*/
  82. // Acquire::Item::Done - Item downloaded OK /*{{{*/
  83. // ---------------------------------------------------------------------
  84. /* */
  85. void pkgAcquire::Item::Done(string Message,unsigned long Size,string)
  86. {
  87. // We just downloaded something..
  88. string FileName = LookupTag(Message,"Filename");
  89. if (Complete == false && FileName == DestFile)
  90. {
  91. if (Owner->Log != 0)
  92. Owner->Log->Fetched(Size,atoi(LookupTag(Message,"Resume-Point","0").c_str()));
  93. }
  94. if (FileSize == 0)
  95. FileSize= Size;
  96. Status = StatDone;
  97. ErrorText = string();
  98. Owner->Dequeue(this);
  99. }
  100. /*}}}*/
  101. // Acquire::Item::Rename - Rename a file /*{{{*/
  102. // ---------------------------------------------------------------------
  103. /* This helper function is used by alot of item methods as thier final
  104. step */
  105. void pkgAcquire::Item::Rename(string From,string To)
  106. {
  107. if (rename(From.c_str(),To.c_str()) != 0)
  108. {
  109. char S[300];
  110. sprintf(S,"rename failed, %s (%s -> %s).",strerror(errno),
  111. From.c_str(),To.c_str());
  112. Status = StatError;
  113. ErrorText = S;
  114. }
  115. }
  116. /*}}}*/
  117. // AcqIndex::AcqIndex - Constructor /*{{{*/
  118. // ---------------------------------------------------------------------
  119. /* The package file is added to the queue and a second class is
  120. instantiated to fetch the revision file */
  121. pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,const pkgSourceList::Item *Location) :
  122. Item(Owner), Location(Location)
  123. {
  124. Decompression = false;
  125. Erase = false;
  126. DestFile = _config->FindDir("Dir::State::lists") + "partial/";
  127. DestFile += URItoFileName(Location->PackagesURI());
  128. // Create the item
  129. Desc.URI = Location->PackagesURI() + ".gz";
  130. Desc.Description = Location->PackagesInfo();
  131. Desc.Owner = this;
  132. // Set the short description to the archive component
  133. if (Location->Dist[Location->Dist.size() - 1] == '/')
  134. Desc.ShortDesc = Location->Dist;
  135. else
  136. Desc.ShortDesc = Location->Dist + '/' + Location->Section;
  137. QueueURI(Desc);
  138. // Create the Release fetch class
  139. new pkgAcqIndexRel(Owner,Location);
  140. }
  141. /*}}}*/
  142. // AcqIndex::Custom600Headers - Insert custom request headers /*{{{*/
  143. // ---------------------------------------------------------------------
  144. /* The only header we use is the last-modified header. */
  145. string pkgAcqIndex::Custom600Headers()
  146. {
  147. string Final = _config->FindDir("Dir::State::lists");
  148. Final += URItoFileName(Location->PackagesURI());
  149. struct stat Buf;
  150. if (stat(Final.c_str(),&Buf) != 0)
  151. return "\nIndex-File: true";
  152. return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
  153. }
  154. /*}}}*/
  155. // AcqIndex::Done - Finished a fetch /*{{{*/
  156. // ---------------------------------------------------------------------
  157. /* This goes through a number of states.. On the initial fetch the
  158. method could possibly return an alternate filename which points
  159. to the uncompressed version of the file. If this is so the file
  160. is copied into the partial directory. In all other cases the file
  161. is decompressed with a gzip uri. */
  162. void pkgAcqIndex::Done(string Message,unsigned long Size,string MD5)
  163. {
  164. Item::Done(Message,Size,MD5);
  165. if (Decompression == true)
  166. {
  167. // Done, move it into position
  168. string FinalFile = _config->FindDir("Dir::State::lists");
  169. FinalFile += URItoFileName(Location->PackagesURI());
  170. Rename(DestFile,FinalFile);
  171. /* We restore the original name to DestFile so that the clean operation
  172. will work OK */
  173. DestFile = _config->FindDir("Dir::State::lists") + "partial/";
  174. DestFile += URItoFileName(Location->PackagesURI());
  175. // Remove the compressed version.
  176. if (Erase == true)
  177. unlink(DestFile.c_str());
  178. return;
  179. }
  180. Erase = false;
  181. Complete = true;
  182. // Handle the unzipd case
  183. string FileName = LookupTag(Message,"Alt-Filename");
  184. if (FileName.empty() == false)
  185. {
  186. // The files timestamp matches
  187. if (StringToBool(LookupTag(Message,"Alt-IMS-Hit"),false) == true)
  188. return;
  189. Decompression = true;
  190. Local = true;
  191. DestFile += ".decomp";
  192. Desc.URI = "copy:" + FileName;
  193. QueueURI(Desc);
  194. Mode = "copy";
  195. return;
  196. }
  197. FileName = LookupTag(Message,"Filename");
  198. if (FileName.empty() == true)
  199. {
  200. Status = StatError;
  201. ErrorText = "Method gave a blank filename";
  202. }
  203. // The files timestamp matches
  204. if (StringToBool(LookupTag(Message,"IMS-Hit"),false) == true)
  205. return;
  206. if (FileName == DestFile)
  207. Erase = true;
  208. else
  209. Local = true;
  210. Decompression = true;
  211. DestFile += ".decomp";
  212. Desc.URI = "gzip:" + FileName,Location->PackagesInfo();
  213. QueueURI(Desc);
  214. Mode = "gzip";
  215. }
  216. /*}}}*/
  217. // AcqIndexRel::pkgAcqIndexRel - Constructor /*{{{*/
  218. // ---------------------------------------------------------------------
  219. /* The Release file is added to the queue */
  220. pkgAcqIndexRel::pkgAcqIndexRel(pkgAcquire *Owner,
  221. const pkgSourceList::Item *Location) :
  222. Item(Owner), Location(Location)
  223. {
  224. DestFile = _config->FindDir("Dir::State::lists") + "partial/";
  225. DestFile += URItoFileName(Location->ReleaseURI());
  226. // Create the item
  227. Desc.URI = Location->ReleaseURI();
  228. Desc.Description = Location->ReleaseInfo();
  229. Desc.Owner = this;
  230. // Set the short description to the archive component
  231. if (Location->Dist[Location->Dist.size() - 1] == '/')
  232. Desc.ShortDesc = Location->Dist;
  233. else
  234. Desc.ShortDesc = Location->Dist + '/' + Location->Section;
  235. QueueURI(Desc);
  236. }
  237. /*}}}*/
  238. // AcqIndexRel::Custom600Headers - Insert custom request headers /*{{{*/
  239. // ---------------------------------------------------------------------
  240. /* The only header we use is the last-modified header. */
  241. string pkgAcqIndexRel::Custom600Headers()
  242. {
  243. string Final = _config->FindDir("Dir::State::lists");
  244. Final += URItoFileName(Location->ReleaseURI());
  245. struct stat Buf;
  246. if (stat(Final.c_str(),&Buf) != 0)
  247. return "\nIndex-File: true";
  248. return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
  249. }
  250. /*}}}*/
  251. // AcqIndexRel::Done - Item downloaded OK /*{{{*/
  252. // ---------------------------------------------------------------------
  253. /* The release file was not placed into the download directory then
  254. a copy URI is generated and it is copied there otherwise the file
  255. in the partial directory is moved into .. and the URI is finished. */
  256. void pkgAcqIndexRel::Done(string Message,unsigned long Size,string MD5)
  257. {
  258. Item::Done(Message,Size,MD5);
  259. string FileName = LookupTag(Message,"Filename");
  260. if (FileName.empty() == true)
  261. {
  262. Status = StatError;
  263. ErrorText = "Method gave a blank filename";
  264. return;
  265. }
  266. Complete = true;
  267. // The files timestamp matches
  268. if (StringToBool(LookupTag(Message,"IMS-Hit"),false) == true)
  269. return;
  270. // We have to copy it into place
  271. if (FileName != DestFile)
  272. {
  273. Local = true;
  274. Desc.URI = "copy:" + FileName;
  275. QueueURI(Desc);
  276. return;
  277. }
  278. // Done, move it into position
  279. string FinalFile = _config->FindDir("Dir::State::lists");
  280. FinalFile += URItoFileName(Location->ReleaseURI());
  281. Rename(DestFile,FinalFile);
  282. }
  283. /*}}}*/
  284. // AcqIndexRel::Failed - Silence failure messages for missing rel files /*{{{*/
  285. // ---------------------------------------------------------------------
  286. /* */
  287. void pkgAcqIndexRel::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
  288. {
  289. if (Cnf->LocalOnly == true ||
  290. StringToBool(LookupTag(Message,"Transient-Failure"),false) == false)
  291. {
  292. // Ignore this
  293. Status = StatDone;
  294. Complete = false;
  295. Dequeue();
  296. return;
  297. }
  298. Item::Failed(Message,Cnf);
  299. }
  300. /*}}}*/
  301. // AcqArchive::AcqArchive - Constructor /*{{{*/
  302. // ---------------------------------------------------------------------
  303. /* This just sets up the initial fetch environment and queues the first
  304. possibilitiy */
  305. pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
  306. pkgRecords *Recs,pkgCache::VerIterator const &Version,
  307. string &StoreFilename) :
  308. Item(Owner), Version(Version), Sources(Sources), Recs(Recs),
  309. StoreFilename(StoreFilename), Vf(Version.FileList())
  310. {
  311. Retries = _config->FindI("Acquire::Retries",0);
  312. if (Version.Arch() == 0)
  313. {
  314. _error->Error("I wasn't able to locate file for the %s package. "
  315. "This might mean you need to manually fix this package. (due to missing arch)",
  316. Version.ParentPkg().Name());
  317. return;
  318. }
  319. // Generate the final file name as: package_version_arch.deb
  320. StoreFilename = QuoteString(Version.ParentPkg().Name(),"_:") + '_' +
  321. QuoteString(Version.VerStr(),"_:") + '_' +
  322. QuoteString(Version.Arch(),"_:.") + ".deb";
  323. // Select a source
  324. if (QueueNext() == false && _error->PendingError() == false)
  325. _error->Error("I wasn't able to locate file for the %s package. "
  326. "This might mean you need to manually fix this package.",
  327. Version.ParentPkg().Name());
  328. }
  329. /*}}}*/
  330. // AcqArchive::QueueNext - Queue the next file source /*{{{*/
  331. // ---------------------------------------------------------------------
  332. /* This queues the next available file version for download. It checks if
  333. the archive is already available in the cache and stashs the MD5 for
  334. checking later. */
  335. bool pkgAcqArchive::QueueNext()
  336. {
  337. for (; Vf.end() == false; Vf++)
  338. {
  339. // Ignore not source sources
  340. if ((Vf.File()->Flags & pkgCache::Flag::NotSource) != 0)
  341. continue;
  342. // Try to cross match against the source list
  343. string PkgFile = flNotDir(Vf.File().FileName());
  344. pkgSourceList::const_iterator Location;
  345. for (Location = Sources->begin(); Location != Sources->end(); Location++)
  346. if (PkgFile == URItoFileName(Location->PackagesURI()))
  347. break;
  348. if (Location == Sources->end())
  349. continue;
  350. // Grab the text package record
  351. pkgRecords::Parser &Parse = Recs->Lookup(Vf);
  352. if (_error->PendingError() == true)
  353. return false;
  354. PkgFile = Parse.FileName();
  355. MD5 = Parse.MD5Hash();
  356. if (PkgFile.empty() == true)
  357. return _error->Error("The package index files are corrupted. No Filename: "
  358. "field for package %s."
  359. ,Version.ParentPkg().Name());
  360. // See if we already have the file. (Legacy filenames)
  361. FileSize = Version->Size;
  362. string FinalFile = _config->FindDir("Dir::Cache::Archives") + flNotDir(PkgFile);
  363. struct stat Buf;
  364. if (stat(FinalFile.c_str(),&Buf) == 0)
  365. {
  366. // Make sure the size matches
  367. if ((unsigned)Buf.st_size == Version->Size)
  368. {
  369. Complete = true;
  370. Local = true;
  371. Status = StatDone;
  372. StoreFilename = DestFile = FinalFile;
  373. return true;
  374. }
  375. /* Hmm, we have a file and its size does not match, this means it is
  376. an old style mismatched arch */
  377. unlink(FinalFile.c_str());
  378. }
  379. // Check it again using the new style output filenames
  380. FinalFile = _config->FindDir("Dir::Cache::Archives") + flNotDir(StoreFilename);
  381. if (stat(FinalFile.c_str(),&Buf) == 0)
  382. {
  383. // Make sure the size matches
  384. if ((unsigned)Buf.st_size == Version->Size)
  385. {
  386. Complete = true;
  387. Local = true;
  388. Status = StatDone;
  389. StoreFilename = DestFile = FinalFile;
  390. return true;
  391. }
  392. /* Hmm, we have a file and its size does not match, this shouldnt
  393. happen.. */
  394. unlink(FinalFile.c_str());
  395. }
  396. DestFile = _config->FindDir("Dir::Cache::Archives") + "partial/" + flNotDir(StoreFilename);
  397. // Check the destination file
  398. if (stat(DestFile.c_str(),&Buf) == 0)
  399. {
  400. // Hmm, the partial file is too big, erase it
  401. if ((unsigned)Buf.st_size > Version->Size)
  402. unlink(DestFile.c_str());
  403. else
  404. PartialSize = Buf.st_size;
  405. }
  406. // Create the item
  407. Desc.URI = Location->ArchiveURI(PkgFile);
  408. Desc.Description = Location->ArchiveInfo(Version);
  409. Desc.Owner = this;
  410. Desc.ShortDesc = Version.ParentPkg().Name();
  411. QueueURI(Desc);
  412. Vf++;
  413. return true;
  414. }
  415. return false;
  416. }
  417. /*}}}*/
  418. // AcqArchive::Done - Finished fetching /*{{{*/
  419. // ---------------------------------------------------------------------
  420. /* */
  421. void pkgAcqArchive::Done(string Message,unsigned long Size,string Md5Hash)
  422. {
  423. Item::Done(Message,Size,Md5Hash);
  424. // Check the size
  425. if (Size != Version->Size)
  426. {
  427. Status = StatError;
  428. ErrorText = "Size mismatch";
  429. return;
  430. }
  431. // Check the md5
  432. if (Md5Hash.empty() == false && MD5.empty() == false)
  433. {
  434. if (Md5Hash != MD5)
  435. {
  436. Status = StatError;
  437. ErrorText = "MD5Sum mismatch";
  438. Rename(DestFile,DestFile + ".FAILED");
  439. return;
  440. }
  441. }
  442. // Grab the output filename
  443. string FileName = LookupTag(Message,"Filename");
  444. if (FileName.empty() == true)
  445. {
  446. Status = StatError;
  447. ErrorText = "Method gave a blank filename";
  448. return;
  449. }
  450. Complete = true;
  451. // Reference filename
  452. if (FileName != DestFile)
  453. {
  454. StoreFilename = DestFile = FileName;
  455. Local = true;
  456. return;
  457. }
  458. // Done, move it into position
  459. string FinalFile = _config->FindDir("Dir::Cache::Archives");
  460. FinalFile += flNotDir(StoreFilename);
  461. Rename(DestFile,FinalFile);
  462. StoreFilename = DestFile = FinalFile;
  463. Complete = true;
  464. }
  465. /*}}}*/
  466. // AcqArchive::Failed - Failure handler /*{{{*/
  467. // ---------------------------------------------------------------------
  468. /* Here we try other sources */
  469. void pkgAcqArchive::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
  470. {
  471. ErrorText = LookupTag(Message,"Message");
  472. if (QueueNext() == false)
  473. {
  474. // This is the retry counter
  475. if (Retries != 0 &&
  476. Cnf->LocalOnly == false &&
  477. StringToBool(LookupTag(Message,"Transient-Failure"),false) == true)
  478. {
  479. Retries--;
  480. Vf = Version.FileList();
  481. if (QueueNext() == true)
  482. return;
  483. }
  484. StoreFilename = string();
  485. Item::Failed(Message,Cnf);
  486. }
  487. }
  488. /*}}}*/
  489. // AcqArchive::Finished - Fetching has finished, tidy up /*{{{*/
  490. // ---------------------------------------------------------------------
  491. /* */
  492. void pkgAcqArchive::Finished()
  493. {
  494. if (Status == pkgAcquire::Item::StatDone &&
  495. Complete == true)
  496. return;
  497. StoreFilename = string();
  498. }
  499. /*}}}*/
  500. // AcqFile::pkgAcqFile - Constructor /*{{{*/
  501. // ---------------------------------------------------------------------
  502. /* The file is added to the queue */
  503. pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string MD5,
  504. unsigned long Size,string Dsc,string ShortDesc) :
  505. Item(Owner), Md5Hash(MD5)
  506. {
  507. Retries = _config->FindI("Acquire::Retries",0);
  508. DestFile = flNotDir(URI);
  509. // Create the item
  510. Desc.URI = URI;
  511. Desc.Description = Dsc;
  512. Desc.Owner = this;
  513. // Set the short description to the archive component
  514. Desc.ShortDesc = ShortDesc;
  515. // Get the transfer sizes
  516. FileSize = Size;
  517. struct stat Buf;
  518. if (stat(DestFile.c_str(),&Buf) == 0)
  519. {
  520. // Hmm, the partial file is too big, erase it
  521. if ((unsigned)Buf.st_size > Size)
  522. unlink(DestFile.c_str());
  523. else
  524. PartialSize = Buf.st_size;
  525. }
  526. QueueURI(Desc);
  527. }
  528. /*}}}*/
  529. // AcqFile::Done - Item downloaded OK /*{{{*/
  530. // ---------------------------------------------------------------------
  531. /* */
  532. void pkgAcqFile::Done(string Message,unsigned long Size,string MD5)
  533. {
  534. // Check the md5
  535. if (Md5Hash.empty() == false && MD5.empty() == false)
  536. {
  537. if (Md5Hash != MD5)
  538. {
  539. Status = StatError;
  540. ErrorText = "MD5Sum mismatch";
  541. Rename(DestFile,DestFile + ".FAILED");
  542. return;
  543. }
  544. }
  545. Item::Done(Message,Size,MD5);
  546. string FileName = LookupTag(Message,"Filename");
  547. if (FileName.empty() == true)
  548. {
  549. Status = StatError;
  550. ErrorText = "Method gave a blank filename";
  551. return;
  552. }
  553. Complete = true;
  554. // The files timestamp matches
  555. if (StringToBool(LookupTag(Message,"IMS-Hit"),false) == true)
  556. return;
  557. // We have to copy it into place
  558. if (FileName != DestFile)
  559. {
  560. Local = true;
  561. if (_config->FindB("Acquire::Source-Symlinks",true) == false)
  562. {
  563. Desc.URI = "copy:" + FileName;
  564. QueueURI(Desc);
  565. return;
  566. }
  567. // Erase the file if it is a symlink so we can overwrite it
  568. struct stat St;
  569. if (lstat(DestFile.c_str(),&St) == 0)
  570. {
  571. if (S_ISLNK(St.st_mode) != 0)
  572. unlink(DestFile.c_str());
  573. }
  574. // Symlink the file
  575. if (symlink(FileName.c_str(),DestFile.c_str()) != 0)
  576. {
  577. ErrorText = "Link to " + DestFile + " failure ";
  578. Status = StatError;
  579. Complete = false;
  580. }
  581. }
  582. }
  583. /*}}}*/
  584. // AcqFile::Failed - Failure handler /*{{{*/
  585. // ---------------------------------------------------------------------
  586. /* Here we try other sources */
  587. void pkgAcqFile::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
  588. {
  589. ErrorText = LookupTag(Message,"Message");
  590. // This is the retry counter
  591. if (Retries != 0 &&
  592. Cnf->LocalOnly == false &&
  593. StringToBool(LookupTag(Message,"Transient-Failure"),false) == true)
  594. {
  595. Retries--;
  596. QueueURI(Desc);
  597. return;
  598. }
  599. Item::Failed(Message,Cnf);
  600. }
  601. /*}}}*/