acquire-item.cc 20 KB

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