acquire-item.h 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. /* ######################################################################
  4. Acquire Item - Item to acquire
  5. When an item is instantiated it will add it self to the local list in
  6. the Owner Acquire class. Derived classes will then call QueueURI to
  7. register all the URI's they wish to fetch at the initial moment.
  8. Three item classes are provided to provide functionality for
  9. downloading of Index, Translation and Packages files.
  10. A Archive class is provided for downloading .deb files. It does Hash
  11. checking and source location as well as a retry algorithm.
  12. ##################################################################### */
  13. /*}}}*/
  14. #ifndef PKGLIB_ACQUIRE_ITEM_H
  15. #define PKGLIB_ACQUIRE_ITEM_H
  16. #include <apt-pkg/acquire.h>
  17. #include <apt-pkg/indexfile.h>
  18. #include <apt-pkg/hashes.h>
  19. #include <apt-pkg/weakptr.h>
  20. #include <apt-pkg/pkgcache.h>
  21. #include <apt-pkg/cacheiterators.h>
  22. #include <string>
  23. #include <vector>
  24. #include <map>
  25. #ifndef APT_8_CLEANER_HEADERS
  26. #include <apt-pkg/sourcelist.h>
  27. #include <apt-pkg/pkgrecords.h>
  28. #endif
  29. /** \addtogroup acquire
  30. * @{
  31. *
  32. * \file acquire-item.h
  33. */
  34. class pkgRecords;
  35. class pkgSourceList;
  36. class pkgAcqMetaClearSig;
  37. class pkgAcqIndexMergeDiffs;
  38. class metaIndex;
  39. class pkgAcquire::Item : public WeakPointable /*{{{*/
  40. /** \brief Represents the process by which a pkgAcquire object should
  41. * retrieve a file or a collection of files.
  42. *
  43. * By convention, Item subclasses should insert themselves into the
  44. * acquire queue when they are created by calling QueueURI(), and
  45. * remove themselves by calling Dequeue() when either Done() or
  46. * Failed() is invoked. Item objects are also responsible for
  47. * notifying the download progress indicator (accessible via
  48. * #Owner->Log) of their status.
  49. *
  50. * \see pkgAcquire
  51. */
  52. {
  53. public:
  54. /** \brief The current status of this item. */
  55. enum ItemState
  56. {
  57. /** \brief The item is waiting to be downloaded. */
  58. StatIdle,
  59. /** \brief The item is currently being downloaded. */
  60. StatFetching,
  61. /** \brief The item has been successfully downloaded. */
  62. StatDone,
  63. /** \brief An error was encountered while downloading this
  64. * item.
  65. */
  66. StatError,
  67. /** \brief The item was downloaded but its authenticity could
  68. * not be verified.
  69. */
  70. StatAuthError,
  71. /** \brief The item was could not be downloaded because of
  72. * a transient network error (e.g. network down)
  73. */
  74. StatTransientNetworkError,
  75. } Status;
  76. /** \brief Contains a textual description of the error encountered
  77. * if #ItemState is #StatError or #StatAuthError.
  78. */
  79. std::string ErrorText;
  80. /** \brief The size of the object to fetch. */
  81. unsigned long long FileSize;
  82. /** \brief How much of the object was already fetched. */
  83. unsigned long long PartialSize;
  84. /** \brief If not \b NULL, contains the name of a subprocess that
  85. * is operating on this object (for instance, "gzip" or "gpgv").
  86. */
  87. APT_DEPRECATED_MSG("Use the std::string member ActiveSubprocess instead") const char *Mode;
  88. /** \brief contains the name of the subprocess that is operating on this object
  89. * (for instance, "gzip", "rred" or "gpgv"). This is obsoleting #Mode from above
  90. * as it can manage the lifetime of included string properly. */
  91. std::string ActiveSubprocess;
  92. /** \brief A client-supplied unique identifier.
  93. *
  94. * This field is initalized to 0; it is meant to be filled in by
  95. * clients that wish to use it to uniquely identify items.
  96. *
  97. * APT progress reporting will store an ID there as shown in "Get:42 …"
  98. */
  99. unsigned long ID;
  100. /** \brief If \b true, the entire object has been successfully fetched.
  101. *
  102. * Subclasses should set this to \b true when appropriate.
  103. */
  104. bool Complete;
  105. /** \brief If \b true, the URI of this object is "local".
  106. *
  107. * The only effect of this field is to exclude the object from the
  108. * download progress indicator's overall statistics.
  109. */
  110. bool Local;
  111. std::string UsedMirror;
  112. /** \brief The number of fetch queues into which this item has been
  113. * inserted.
  114. *
  115. * There is one queue for each source from which an item could be
  116. * downloaded.
  117. *
  118. * \sa pkgAcquire
  119. */
  120. unsigned int QueueCounter;
  121. /** \brief The number of additional fetch items that are expected
  122. * once this item is done.
  123. *
  124. * Some items like pkgAcqMeta{Index,Sig} will queue additional
  125. * items. This variable can be set by the methods if it knows
  126. * in advance how many items to expect to get a more accurate
  127. * progress.
  128. */
  129. unsigned int ExpectedAdditionalItems;
  130. /** \brief The name of the file into which the retrieved object
  131. * will be written.
  132. */
  133. std::string DestFile;
  134. /** \brief Invoked by the acquire worker when the object couldn't
  135. * be fetched.
  136. *
  137. * This is a branch of the continuation of the fetch process.
  138. *
  139. * \param Message An RFC822-formatted message from the acquire
  140. * method describing what went wrong. Use LookupTag() to parse
  141. * it.
  142. *
  143. * \param Cnf The method via which the worker tried to fetch this object.
  144. *
  145. * \sa pkgAcqMethod
  146. */
  147. virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf);
  148. /** \brief Invoked by the acquire worker to check if the successfully
  149. * fetched object is also the objected we wanted to have.
  150. *
  151. * Note that the object might \e not have been written to
  152. * DestFile; check for the presence of an Alt-Filename entry in
  153. * Message to find the file to which it was really written.
  154. *
  155. * This is called before Done is called and can prevent it by returning
  156. * \b false which will result in Failed being called instead.
  157. *
  158. * You should prefer to use this method over calling Failed() from Done()
  159. * as this has e.g. the wrong progress reporting.
  160. *
  161. * \param Message Data from the acquire method. Use LookupTag()
  162. * to parse it.
  163. * \param Cnf The method via which the object was fetched.
  164. *
  165. * \sa pkgAcqMethod
  166. */
  167. virtual bool VerifyDone(std::string const &Message,
  168. pkgAcquire::MethodConfig const * const Cnf);
  169. /** \brief Invoked by the acquire worker when the object was
  170. * fetched successfully.
  171. *
  172. * Note that the object might \e not have been written to
  173. * DestFile; check for the presence of an Alt-Filename entry in
  174. * Message to find the file to which it was really written.
  175. *
  176. * Done is often used to switch from one stage of the processing
  177. * to the next (e.g. fetching, unpacking, copying). It is one
  178. * branch of the continuation of the fetch process.
  179. *
  180. * \param Message Data from the acquire method. Use LookupTag()
  181. * to parse it.
  182. * \param Hashes The HashSums of the object that was fetched.
  183. * \param Cnf The method via which the object was fetched.
  184. *
  185. * \sa pkgAcqMethod
  186. */
  187. virtual void Done(std::string const &Message, HashStringList const &Hashes,
  188. pkgAcquire::MethodConfig const * const Cnf);
  189. /** \brief Invoked when the worker starts to fetch this object.
  190. *
  191. * \param Message RFC822-formatted data from the worker process.
  192. * Use LookupTag() to parse it.
  193. *
  194. * \param Hashes The expected hashes of the object being fetched.
  195. *
  196. * \sa pkgAcqMethod
  197. */
  198. virtual void Start(std::string const &Message, unsigned long long const Size);
  199. /** \brief Custom headers to be sent to the fetch process.
  200. *
  201. * \return a string containing RFC822-style headers that are to be
  202. * inserted into the 600 URI Acquire message sent to the fetch
  203. * subprocess. The headers are inserted after a newline-less
  204. * line, so they should (if nonempty) have a leading newline and
  205. * no trailing newline.
  206. */
  207. virtual std::string Custom600Headers() const;
  208. /** \brief A "descriptive" URI-like string.
  209. *
  210. * \return a URI that should be used to describe what is being fetched.
  211. */
  212. virtual std::string DescURI() const = 0;
  213. /** \brief Short item description.
  214. *
  215. * \return a brief description of the object being fetched.
  216. */
  217. virtual std::string ShortDesc() const;
  218. /** \brief Invoked by the worker when the download is completely done. */
  219. virtual void Finished();
  220. /** \return HashSums the DestFile is supposed to have in this stage */
  221. virtual HashStringList GetExpectedHashes() const = 0;
  222. /** \return the 'best' hash for display proposes like --print-uris */
  223. std::string HashSum() const;
  224. /** \return if having no hashes is a hard failure or not
  225. *
  226. * Idealy this is always \b true for every subclass, but thanks to
  227. * historical grow we don't have hashes for all files in all cases
  228. * in all steps, so it is slightly more complicated than it should be.
  229. */
  230. virtual bool HashesRequired() const { return true; }
  231. /** \return the acquire process with which this item is associated. */
  232. pkgAcquire *GetOwner() const;
  233. pkgAcquire::ItemDesc &GetItemDesc();
  234. /** \return \b true if this object is being fetched from a trusted source. */
  235. virtual bool IsTrusted() const;
  236. /** \brief Report mirror problem
  237. *
  238. * This allows reporting mirror failures back to a centralized
  239. * server. The apt-report-mirror-failure script is called for this
  240. *
  241. * \param FailCode A short failure string that is send
  242. */
  243. APT_DEPRECATED_MSG("Item::Failed does this for you") void ReportMirrorFailure(std::string const &FailCode);
  244. /** \brief Set the name of the current active subprocess
  245. *
  246. * See also #ActiveSubprocess
  247. */
  248. void SetActiveSubprocess(std::string const &subprocess);
  249. /** \brief Initialize an item.
  250. *
  251. * Adds the item to the list of items known to the acquire
  252. * process, but does not place it into any fetch queues (you must
  253. * manually invoke QueueURI() to do so).
  254. *
  255. * \param Owner The new owner of this item.
  256. */
  257. explicit Item(pkgAcquire * const Owner);
  258. /** \brief Remove this item from its owner's queue by invoking
  259. * pkgAcquire::Remove.
  260. */
  261. virtual ~Item();
  262. bool APT_HIDDEN IsRedirectionLoop(std::string const &NewURI);
  263. protected:
  264. /** \brief The acquire object with which this item is associated. */
  265. pkgAcquire * const Owner;
  266. /** \brief The item that is currently being downloaded. */
  267. pkgAcquire::ItemDesc Desc;
  268. enum RenameOnErrorState {
  269. HashSumMismatch,
  270. SizeMismatch,
  271. InvalidFormat,
  272. SignatureError,
  273. NotClearsigned,
  274. MaximumSizeExceeded,
  275. PDiffError,
  276. };
  277. /** \brief Rename failed file and set error
  278. *
  279. * \param state respresenting the error we encountered
  280. */
  281. bool RenameOnError(RenameOnErrorState const state);
  282. /** \brief Insert this item into its owner's queue.
  283. *
  284. * The method is designed to check if the request would end
  285. * in an IMSHit and if it determines that it would, it isn't
  286. * queueing the Item and instead sets it to completion instantly.
  287. *
  288. * \param Item Metadata about this item (its URI and
  289. * description).
  290. * \return true if the item was inserted, false if IMSHit was detected
  291. */
  292. virtual bool QueueURI(ItemDesc &Item);
  293. /** \brief Remove this item from its owner's queue. */
  294. void Dequeue();
  295. /** \brief Rename a file without modifying its timestamp.
  296. *
  297. * Many item methods call this as their final action.
  298. *
  299. * \param From The file to be renamed.
  300. *
  301. * \param To The new name of \a From. If \a To exists it will be
  302. * overwritten. If \a From and \a To are equal nothing happens.
  303. */
  304. bool Rename(std::string const &From, std::string const &To);
  305. /** \brief Get the full pathname of the final file for the current URI */
  306. virtual std::string GetFinalFilename() const;
  307. private:
  308. class Private;
  309. Private * const d;
  310. friend class pkgAcqMetaBase;
  311. friend class pkgAcqMetaClearSig;
  312. };
  313. /*}}}*/
  314. class APT_HIDDEN pkgAcqTransactionItem: public pkgAcquire::Item /*{{{*/
  315. /** \brief baseclass for the indexes files to manage them all together */
  316. {
  317. void * const d;
  318. protected:
  319. HashStringList GetExpectedHashesFor(std::string const &MetaKey) const;
  320. bool QueueURI(pkgAcquire::ItemDesc &Item) APT_OVERRIDE;
  321. public:
  322. IndexTarget const Target;
  323. /** \brief storge name until a transaction is finished */
  324. std::string PartialFile;
  325. /** \brief TransactionManager */
  326. pkgAcqMetaClearSig * const TransactionManager;
  327. enum TransactionStates {
  328. TransactionStarted,
  329. TransactionCommit,
  330. TransactionAbort,
  331. };
  332. virtual bool TransactionState(TransactionStates const state);
  333. virtual std::string DescURI() const APT_OVERRIDE { return Target.URI; }
  334. virtual HashStringList GetExpectedHashes() const APT_OVERRIDE;
  335. virtual std::string GetMetaKey() const;
  336. virtual bool HashesRequired() const APT_OVERRIDE;
  337. pkgAcqTransactionItem(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager, IndexTarget const &Target) APT_NONNULL(2, 3);
  338. virtual ~pkgAcqTransactionItem();
  339. friend class pkgAcqMetaBase;
  340. friend class pkgAcqMetaClearSig;
  341. };
  342. /*}}}*/
  343. class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem /*{{{*/
  344. /** \brief the manager of a transaction */
  345. {
  346. void * const d;
  347. protected:
  348. std::vector<pkgAcqTransactionItem*> Transaction;
  349. /** \brief If \b true, the index's signature is currently being verified.
  350. */
  351. bool AuthPass;
  352. /** \brief Called when a file is finished being retrieved.
  353. *
  354. * If the file was not downloaded to DestFile, a copy process is
  355. * set up to copy it to DestFile; otherwise, Complete is set to \b
  356. * true and the file is moved to its final location.
  357. *
  358. * \param Message The message block received from the fetch
  359. * subprocess.
  360. */
  361. bool CheckDownloadDone(pkgAcqTransactionItem * const I, const std::string &Message, HashStringList const &Hashes) const;
  362. /** \brief Queue the downloaded Signature for verification */
  363. void QueueForSignatureVerify(pkgAcqTransactionItem * const I, std::string const &File, std::string const &Signature);
  364. virtual std::string Custom600Headers() const APT_OVERRIDE;
  365. /** \brief Called when authentication succeeded.
  366. *
  367. * Sanity-checks the authenticated file, queues up the individual
  368. * index files for download, and saves the signature in the lists
  369. * directory next to the authenticated list file.
  370. *
  371. * \param Message The message block received from the fetch
  372. * subprocess.
  373. */
  374. bool CheckAuthDone(std::string const &Message);
  375. /** Check if the current item should fail at this point */
  376. bool CheckStopAuthentication(pkgAcquire::Item * const I, const std::string &Message);
  377. /** \brief Check that the release file is a release file for the
  378. * correct distribution.
  379. *
  380. * \return \b true if no fatal errors were encountered.
  381. */
  382. bool VerifyVendor(std::string const &Message);
  383. virtual bool TransactionState(TransactionStates const state) APT_OVERRIDE;
  384. public:
  385. // This refers more to the Transaction-Manager than the actual file
  386. bool IMSHit;
  387. TransactionStates State;
  388. std::string BaseURI;
  389. virtual bool QueueURI(pkgAcquire::ItemDesc &Item) APT_OVERRIDE;
  390. virtual HashStringList GetExpectedHashes() const APT_OVERRIDE;
  391. virtual bool HashesRequired() const APT_OVERRIDE;
  392. // transaction code
  393. void Add(pkgAcqTransactionItem * const I);
  394. void AbortTransaction();
  395. bool TransactionHasError() const;
  396. void CommitTransaction();
  397. /** \brief Stage (queue) a copy action when the transaction is committed
  398. */
  399. void TransactionStageCopy(pkgAcqTransactionItem * const I,
  400. const std::string &From,
  401. const std::string &To);
  402. /** \brief Stage (queue) a removal action when the transaction is committed
  403. */
  404. void TransactionStageRemoval(pkgAcqTransactionItem * const I, const std::string &FinalFile);
  405. /** \brief Get the full pathname of the final file for the current URI */
  406. virtual std::string GetFinalFilename() const APT_OVERRIDE;
  407. pkgAcqMetaBase(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
  408. IndexTarget const &DataTarget) APT_NONNULL(2, 3);
  409. virtual ~pkgAcqMetaBase();
  410. };
  411. /*}}}*/
  412. /** \brief An item that is responsible for downloading the meta-index {{{
  413. * file (i.e., Release) itself and verifying its signature.
  414. *
  415. * Once the download and verification are complete, the downloads of
  416. * the individual index files are queued up using pkgAcqDiffIndex.
  417. * If the meta-index file had a valid signature, the expected hashsums
  418. * of the index files will be the md5sums listed in the meta-index;
  419. * otherwise, the expected hashsums will be "" (causing the
  420. * authentication of the index files to be bypassed).
  421. */
  422. class APT_HIDDEN pkgAcqMetaIndex : public pkgAcqMetaBase
  423. {
  424. void * const d;
  425. protected:
  426. IndexTarget const DetachedSigTarget;
  427. /** \brief delayed constructor */
  428. void Init(std::string const &URIDesc, std::string const &ShortDesc);
  429. public:
  430. virtual std::string DescURI() const APT_OVERRIDE;
  431. // Specialized action members
  432. virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  433. virtual void Done(std::string const &Message, HashStringList const &Hashes,
  434. pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  435. /** \brief Create a new pkgAcqMetaIndex. */
  436. pkgAcqMetaIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
  437. IndexTarget const &DataTarget, IndexTarget const &DetachedSigTarget) APT_NONNULL(2, 3);
  438. virtual ~pkgAcqMetaIndex();
  439. friend class pkgAcqMetaSig;
  440. };
  441. /*}}}*/
  442. /** \brief An acquire item that downloads the detached signature {{{
  443. * of a meta-index (Release) file, then queues up the release
  444. * file itself.
  445. *
  446. * \todo Why protected members?
  447. *
  448. * \sa pkgAcqMetaIndex
  449. */
  450. class APT_HIDDEN pkgAcqMetaSig : public pkgAcqTransactionItem
  451. {
  452. void * const d;
  453. pkgAcqMetaIndex * const MetaIndex;
  454. /** \brief The file we use to verify the MetaIndexFile with (not always set!) */
  455. std::string MetaIndexFileSignature;
  456. protected:
  457. /** \brief Get the full pathname of the final file for the current URI */
  458. virtual std::string GetFinalFilename() const APT_OVERRIDE;
  459. public:
  460. virtual bool HashesRequired() const APT_OVERRIDE { return false; }
  461. // Specialized action members
  462. virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  463. virtual void Done(std::string const &Message, HashStringList const &Hashes,
  464. pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  465. virtual std::string Custom600Headers() const APT_OVERRIDE;
  466. /** \brief Create a new pkgAcqMetaSig. */
  467. pkgAcqMetaSig(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
  468. IndexTarget const &Target, pkgAcqMetaIndex * const MetaIndex) APT_NONNULL(2, 3, 5);
  469. virtual ~pkgAcqMetaSig();
  470. };
  471. /*}}}*/
  472. /** \brief An item repsonsible for downloading clearsigned metaindexes {{{*/
  473. class APT_HIDDEN pkgAcqMetaClearSig : public pkgAcqMetaIndex
  474. {
  475. void * const d;
  476. IndexTarget const DetachedDataTarget;
  477. public:
  478. /** \brief A package-system-specific parser for the meta-index file. */
  479. metaIndex *MetaIndexParser;
  480. metaIndex *LastMetaIndexParser;
  481. virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  482. virtual std::string Custom600Headers() const APT_OVERRIDE;
  483. virtual bool VerifyDone(std::string const &Message, pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  484. virtual void Done(std::string const &Message, HashStringList const &Hashes,
  485. pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  486. virtual void Finished() APT_OVERRIDE;
  487. /** \brief Starts downloading the individual index files.
  488. *
  489. * \param verify If \b true, only indices whose expected hashsum
  490. * can be determined from the meta-index will be downloaded, and
  491. * the hashsums of indices will be checked (reporting
  492. * #StatAuthError if there is a mismatch). If verify is \b false,
  493. * no hashsum checking will be performed.
  494. */
  495. void QueueIndexes(bool const verify);
  496. /** \brief Create a new pkgAcqMetaClearSig. */
  497. pkgAcqMetaClearSig(pkgAcquire * const Owner,
  498. IndexTarget const &ClearsignedTarget,
  499. IndexTarget const &DetachedDataTarget,
  500. IndexTarget const &DetachedSigTarget,
  501. metaIndex * const MetaIndexParser);
  502. virtual ~pkgAcqMetaClearSig();
  503. };
  504. /*}}}*/
  505. /** \brief Common base class for all classes that deal with fetching indexes {{{*/
  506. class APT_HIDDEN pkgAcqBaseIndex : public pkgAcqTransactionItem
  507. {
  508. void * const d;
  509. public:
  510. /** \brief Get the full pathname of the final file for the current URI */
  511. virtual std::string GetFinalFilename() const APT_OVERRIDE;
  512. virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  513. pkgAcqBaseIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
  514. IndexTarget const &Target) APT_NONNULL(2, 3);
  515. virtual ~pkgAcqBaseIndex();
  516. };
  517. /*}}}*/
  518. /** \brief An acquire item that is responsible for fetching an index {{{
  519. * file (e.g., Packages or Sources).
  520. *
  521. * \sa pkgAcqDiffIndex, pkgAcqIndexDiffs, pkgAcqIndexTrans
  522. *
  523. * \todo Why does pkgAcqIndex have protected members?
  524. */
  525. class APT_HIDDEN pkgAcqIndex : public pkgAcqBaseIndex
  526. {
  527. void * const d;
  528. protected:
  529. /** \brief The stages the method goes through
  530. *
  531. * The method first downloads the indexfile, then its decompressed (or
  532. * copied) and verified
  533. */
  534. enum AllStages {
  535. STAGE_DOWNLOAD,
  536. STAGE_DECOMPRESS_AND_VERIFY,
  537. };
  538. AllStages Stage;
  539. /** \brief Handle what needs to be done when the download is done */
  540. void StageDownloadDone(std::string const &Message);
  541. /** \brief Handle what needs to be done when the decompression/copy is
  542. * done
  543. */
  544. void StageDecompressDone();
  545. /** \brief If \b set, this partially downloaded file will be
  546. * removed when the download completes.
  547. */
  548. std::string EraseFileName;
  549. /** \brief The compression-related file extensions that are being
  550. * added to the downloaded file one by one if first fails (e.g., "gz bz2").
  551. */
  552. std::string CompressionExtensions;
  553. /** \brief The actual compression extension currently used */
  554. std::string CurrentCompressionExtension;
  555. /** \brief Do the changes needed to fetch via AptByHash (if needed) */
  556. void InitByHashIfNeeded();
  557. /** \brief Get the full pathname of the final file for the current URI */
  558. virtual std::string GetFinalFilename() const APT_OVERRIDE;
  559. virtual bool TransactionState(TransactionStates const state) APT_OVERRIDE;
  560. public:
  561. // Specialized action members
  562. virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  563. virtual void Done(std::string const &Message, HashStringList const &Hashes,
  564. pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  565. virtual std::string Custom600Headers() const APT_OVERRIDE;
  566. virtual std::string DescURI() const APT_OVERRIDE {return Desc.URI;};
  567. virtual std::string GetMetaKey() const APT_OVERRIDE;
  568. pkgAcqIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
  569. IndexTarget const &Target, bool const Derived = false) APT_NONNULL(2, 3);
  570. virtual ~pkgAcqIndex();
  571. protected:
  572. APT_HIDDEN void Init(std::string const &URI, std::string const &URIDesc,
  573. std::string const &ShortDesc);
  574. APT_HIDDEN bool CommonFailed(std::string const &TargetURI, std::string const TargetDesc,
  575. std::string const &Message, pkgAcquire::MethodConfig const * const Cnf);
  576. };
  577. /*}}}*/
  578. /** \brief An item that is responsible for fetching an index file of {{{
  579. * package list diffs and starting the package list's download.
  580. *
  581. * This item downloads the Index file and parses it, then enqueues
  582. * additional downloads of either the individual patches (using
  583. * pkgAcqIndexDiffs) or the entire Packages file (using pkgAcqIndex).
  584. *
  585. * \sa pkgAcqIndexDiffs, pkgAcqIndex
  586. */
  587. class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqIndex
  588. {
  589. void * const d;
  590. std::vector<pkgAcqIndexMergeDiffs*> * diffs;
  591. protected:
  592. /** \brief If \b true, debugging information will be written to std::clog. */
  593. bool Debug;
  594. /** \brief A description of the Packages file (stored in
  595. * pkgAcquire::ItemDesc::Description).
  596. */
  597. std::string Description;
  598. /** \brief Get the full pathname of the final file for the current URI */
  599. virtual std::string GetFinalFilename() const APT_OVERRIDE;
  600. virtual bool QueueURI(pkgAcquire::ItemDesc &Item) APT_OVERRIDE;
  601. virtual bool TransactionState(TransactionStates const state) APT_OVERRIDE;
  602. public:
  603. // Specialized action members
  604. virtual void Failed(std::string const &Message, pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  605. virtual void Done(std::string const &Message, HashStringList const &Hashes,
  606. pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  607. virtual std::string DescURI() const APT_OVERRIDE {return Target.URI + "Index";};
  608. virtual std::string GetMetaKey() const APT_OVERRIDE;
  609. /** \brief Parse the Index file for a set of Packages diffs.
  610. *
  611. * Parses the Index file and creates additional download items as
  612. * necessary.
  613. *
  614. * \param IndexDiffFile The name of the Index file.
  615. *
  616. * \return \b true if the Index file was successfully parsed, \b
  617. * false otherwise.
  618. */
  619. bool ParseDiffIndex(std::string const &IndexDiffFile);
  620. /** \brief Create a new pkgAcqDiffIndex.
  621. *
  622. * \param Owner The Acquire object that owns this item.
  623. *
  624. * \param URI The URI of the list file to download.
  625. *
  626. * \param URIDesc A long description of the list file to download.
  627. *
  628. * \param ShortDesc A short description of the list file to download.
  629. */
  630. pkgAcqDiffIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
  631. IndexTarget const &Target) APT_NONNULL(2, 3);
  632. virtual ~pkgAcqDiffIndex();
  633. private:
  634. APT_HIDDEN void QueueOnIMSHit() const;
  635. };
  636. /*}}}*/
  637. struct APT_HIDDEN DiffInfo { /*{{{*/
  638. /** The filename of the diff. */
  639. std::string file;
  640. /** The hashes of the file after the diff is applied */
  641. HashStringList result_hashes;
  642. /** The hashes of the diff */
  643. HashStringList patch_hashes;
  644. /** The hashes of the compressed diff */
  645. HashStringList download_hashes;
  646. };
  647. /*}}}*/
  648. /** \brief An item that is responsible for fetching client-merge patches {{{
  649. * that need to be applied to a given package index file.
  650. *
  651. * Instead of downloading and applying each patch one by one like its
  652. * sister #pkgAcqIndexDiffs this class will download all patches at once
  653. * and call rred with all the patches downloaded once. Rred will then
  654. * merge and apply them in one go, which should be a lot faster – but is
  655. * incompatible with server-based merges of patches like reprepro can do.
  656. *
  657. * \sa pkgAcqDiffIndex, pkgAcqIndex
  658. */
  659. class APT_HIDDEN pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex
  660. {
  661. void * const d;
  662. protected:
  663. /** \brief If \b true, debugging output will be written to
  664. * std::clog.
  665. */
  666. bool Debug;
  667. /** \brief description of the file being downloaded. */
  668. std::string Description;
  669. /** \brief information about the current patch */
  670. struct DiffInfo const patch;
  671. /** \brief list of all download items for the patches */
  672. std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches;
  673. /** The current status of this patch. */
  674. enum DiffState
  675. {
  676. /** \brief The diff is currently being fetched. */
  677. StateFetchDiff,
  678. /** \brief The diff is currently being applied. */
  679. StateApplyDiff,
  680. /** \brief the work with this diff is done */
  681. StateDoneDiff,
  682. /** \brief something bad happened and fallback was triggered */
  683. StateErrorDiff
  684. } State;
  685. public:
  686. /** \brief Called when the patch file failed to be downloaded.
  687. *
  688. * This method will fall back to downloading the whole index file
  689. * outright; its arguments are ignored.
  690. */
  691. virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  692. virtual void Done(std::string const &Message, HashStringList const &Hashes,
  693. pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  694. virtual std::string Custom600Headers() const APT_OVERRIDE;
  695. virtual std::string DescURI() const APT_OVERRIDE {return Target.URI + "Index";};
  696. virtual HashStringList GetExpectedHashes() const APT_OVERRIDE;
  697. virtual bool HashesRequired() const APT_OVERRIDE;
  698. /** \brief Create an index merge-diff item.
  699. *
  700. * \param Owner The pkgAcquire object that owns this item.
  701. *
  702. * \param URI The URI of the package index file being
  703. * reconstructed.
  704. *
  705. * \param URIDesc A long description of this item.
  706. *
  707. * \param ShortDesc A brief description of this item.
  708. *
  709. * \param patch contains infos about the patch this item is supposed
  710. * to download which were read from the index
  711. *
  712. * \param allPatches contains all related items so that each item can
  713. * check if it was the last one to complete the download step
  714. */
  715. pkgAcqIndexMergeDiffs(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
  716. IndexTarget const &Target, DiffInfo const &patch,
  717. std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches) APT_NONNULL(2, 3, 6);
  718. virtual ~pkgAcqIndexMergeDiffs();
  719. };
  720. /*}}}*/
  721. /** \brief An item that is responsible for fetching server-merge patches {{{
  722. * that need to be applied to a given package index file.
  723. *
  724. * After downloading and applying a single patch, this item will
  725. * enqueue a new pkgAcqIndexDiffs to download and apply the remaining
  726. * patches. If no patch can be found that applies to an intermediate
  727. * file or if one of the patches cannot be downloaded, falls back to
  728. * downloading the entire package index file using pkgAcqIndex.
  729. *
  730. * \sa pkgAcqDiffIndex, pkgAcqIndex
  731. */
  732. class APT_HIDDEN pkgAcqIndexDiffs : public pkgAcqBaseIndex
  733. {
  734. void * const d;
  735. private:
  736. /** \brief Queue up the next diff download.
  737. *
  738. * Search for the next available diff that applies to the file
  739. * that currently exists on disk, and enqueue it by calling
  740. * QueueURI().
  741. *
  742. * \return \b true if an applicable diff was found, \b false
  743. * otherwise.
  744. */
  745. APT_HIDDEN bool QueueNextDiff();
  746. /** \brief Handle tasks that must be performed after the item
  747. * finishes downloading.
  748. *
  749. * Dequeues the item and checks the resulting file's hashsums
  750. * against ExpectedHashes after the last patch was applied.
  751. * There is no need to check the md5/sha1 after a "normal"
  752. * patch because QueueNextDiff() will check the sha1 later.
  753. *
  754. * \param allDone If \b true, the file was entirely reconstructed,
  755. * and its md5sum is verified.
  756. */
  757. APT_HIDDEN void Finish(bool const allDone=false);
  758. protected:
  759. /** \brief If \b true, debugging output will be written to
  760. * std::clog.
  761. */
  762. bool Debug;
  763. /** A description of the file being downloaded. */
  764. std::string Description;
  765. /** The patches that remain to be downloaded, including the patch
  766. * being downloaded right now. This list should be ordered so
  767. * that each diff appears before any diff that depends on it.
  768. *
  769. * \todo These are indexed by sha1sum; why not use some sort of
  770. * dictionary instead of relying on ordering and stripping them
  771. * off the front?
  772. */
  773. std::vector<DiffInfo> available_patches;
  774. /** The current status of this patch. */
  775. enum DiffState
  776. {
  777. /** \brief The diff is currently being fetched. */
  778. StateFetchDiff,
  779. /** \brief The diff is currently being applied. */
  780. StateApplyDiff
  781. } State;
  782. public:
  783. /** \brief Called when the patch file failed to be downloaded.
  784. *
  785. * This method will fall back to downloading the whole index file
  786. * outright; its arguments are ignored.
  787. */
  788. virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  789. virtual void Done(std::string const &Message, HashStringList const &Hashes,
  790. pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  791. virtual std::string Custom600Headers() const APT_OVERRIDE;
  792. virtual std::string DescURI() const APT_OVERRIDE {return Target.URI + "IndexDiffs";};
  793. virtual HashStringList GetExpectedHashes() const APT_OVERRIDE;
  794. virtual bool HashesRequired() const APT_OVERRIDE;
  795. /** \brief Create an index diff item.
  796. *
  797. * After filling in its basic fields, this invokes Finish(true) if
  798. * \a diffs is empty, or QueueNextDiff() otherwise.
  799. *
  800. * \param Owner The pkgAcquire object that owns this item.
  801. *
  802. * \param URI The URI of the package index file being
  803. * reconstructed.
  804. *
  805. * \param URIDesc A long description of this item.
  806. *
  807. * \param ShortDesc A brief description of this item.
  808. *
  809. * \param diffs The remaining diffs from the index of diffs. They
  810. * should be ordered so that each diff appears before any diff
  811. * that depends on it.
  812. */
  813. pkgAcqIndexDiffs(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
  814. IndexTarget const &Target,
  815. std::vector<DiffInfo> const &diffs=std::vector<DiffInfo>()) APT_NONNULL(2, 3);
  816. virtual ~pkgAcqIndexDiffs();
  817. };
  818. /*}}}*/
  819. /** \brief An item that is responsible for fetching a package file. {{{
  820. *
  821. * If the package file already exists in the cache, nothing will be
  822. * done.
  823. */
  824. class pkgAcqArchive : public pkgAcquire::Item
  825. {
  826. void * const d;
  827. bool LocalSource;
  828. HashStringList ExpectedHashes;
  829. protected:
  830. /** \brief The package version being fetched. */
  831. pkgCache::VerIterator Version;
  832. /** \brief The list of sources from which to pick archives to
  833. * download this package from.
  834. */
  835. pkgSourceList *Sources;
  836. /** \brief A package records object, used to look up the file
  837. * corresponding to each version of the package.
  838. */
  839. pkgRecords *Recs;
  840. /** \brief A location in which the actual filename of the package
  841. * should be stored.
  842. */
  843. std::string &StoreFilename;
  844. /** \brief The next file for this version to try to download. */
  845. pkgCache::VerFileIterator Vf;
  846. /** \brief How many (more) times to try to find a new source from
  847. * which to download this package version if it fails.
  848. *
  849. * Set from Acquire::Retries.
  850. */
  851. unsigned int Retries;
  852. /** \brief \b true if this version file is being downloaded from a
  853. * trusted source.
  854. */
  855. bool Trusted;
  856. /** \brief Queue up the next available file for this version. */
  857. bool QueueNext();
  858. /** \brief Get the full pathname of the final file for the current URI */
  859. virtual std::string GetFinalFilename() const APT_OVERRIDE;
  860. public:
  861. virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  862. virtual void Done(std::string const &Message, HashStringList const &Hashes,
  863. pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  864. virtual std::string DescURI() const APT_OVERRIDE;
  865. virtual std::string ShortDesc() const APT_OVERRIDE;
  866. virtual void Finished() APT_OVERRIDE;
  867. virtual bool IsTrusted() const APT_OVERRIDE;
  868. virtual HashStringList GetExpectedHashes() const APT_OVERRIDE;
  869. virtual bool HashesRequired() const APT_OVERRIDE;
  870. /** \brief Create a new pkgAcqArchive.
  871. *
  872. * \param Owner The pkgAcquire object with which this item is
  873. * associated.
  874. *
  875. * \param Sources The sources from which to download version
  876. * files.
  877. *
  878. * \param Recs A package records object, used to look up the file
  879. * corresponding to each version of the package.
  880. *
  881. * \param Version The package version to download.
  882. *
  883. * \param[out] StoreFilename A location in which the actual filename of
  884. * the package should be stored. It will be set to a guessed
  885. * basename in the constructor, and filled in with a fully
  886. * qualified filename once the download finishes.
  887. */
  888. pkgAcqArchive(pkgAcquire * const Owner,pkgSourceList * const Sources,
  889. pkgRecords * const Recs,pkgCache::VerIterator const &Version,
  890. std::string &StoreFilename);
  891. virtual ~pkgAcqArchive();
  892. };
  893. /*}}}*/
  894. /** \brief Retrieve the changelog for the given version {{{
  895. *
  896. * Downloads the changelog to a temporary file it will also remove again
  897. * while it is deconstructed or downloads it to a named location.
  898. */
  899. class pkgAcqChangelog : public pkgAcquire::Item
  900. {
  901. class Private;
  902. Private * const d;
  903. std::string TemporaryDirectory;
  904. std::string const SrcName;
  905. std::string const SrcVersion;
  906. public:
  907. // we will never have hashes for changelogs.
  908. // If you need verified ones, download the deb and extract the changelog.
  909. virtual HashStringList GetExpectedHashes() const APT_OVERRIDE { return HashStringList(); }
  910. virtual bool HashesRequired() const APT_OVERRIDE { return false; }
  911. // Specialized action members
  912. virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  913. virtual void Done(std::string const &Message, HashStringList const &CalcHashes,
  914. pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  915. virtual std::string DescURI() const APT_OVERRIDE {return Desc.URI;};
  916. /** returns the URI to the changelog of this version
  917. *
  918. * @param Ver is the version to get the changelog for
  919. * @return the URI which will be used to acquire the changelog
  920. */
  921. static std::string URI(pkgCache::VerIterator const &Ver);
  922. /** returns the URI to the changelog of this version
  923. *
  924. * \param Rls is the Release file the package comes from
  925. * \param Component in which the package resides, can be empty
  926. * \param SrcName is the source package name
  927. * \param SrcVersion is the source package version
  928. * @return the URI which will be used to acquire the changelog
  929. */
  930. static std::string URI(pkgCache::RlsFileIterator const &Rls,
  931. char const * const Component, char const * const SrcName,
  932. char const * const SrcVersion);
  933. /** returns the URI to the changelog of this version
  934. *
  935. * \param Template URI where @CHANGEPATH@ has to be filled in
  936. * \param Component in which the package resides, can be empty
  937. * \param SrcName is the source package name
  938. * \param SrcVersion is the source package version
  939. * @return the URI which will be used to acquire the changelog
  940. */
  941. static std::string URI(std::string const &Template,
  942. char const * const Component, char const * const SrcName,
  943. char const * const SrcVersion);
  944. /** returns the URI template for this release file
  945. *
  946. * \param Rls is a Release file
  947. * @return the URI template to use for this release file
  948. */
  949. static std::string URITemplate(pkgCache::RlsFileIterator const &Rls);
  950. /** \brief Create a new pkgAcqChangelog object.
  951. *
  952. * \param Owner The pkgAcquire object with which this object is
  953. * associated.
  954. * \param Ver is the version to get the changelog for
  955. * \param DestDir The directory the file should be downloaded into.
  956. * Will be an autocreated (and cleaned up) temporary directory if not set.
  957. * \param DestFilename The filename the file should have in #DestDir
  958. * Defaults to sourcepackagename.changelog if not set.
  959. */
  960. pkgAcqChangelog(pkgAcquire * const Owner, pkgCache::VerIterator const &Ver,
  961. std::string const &DestDir="", std::string const &DestFilename="");
  962. /** \brief Create a new pkgAcqChangelog object.
  963. *
  964. * \param Owner The pkgAcquire object with which this object is
  965. * associated.
  966. * \param Rls is the Release file the package comes from
  967. * \param Component in which the package resides, can be empty
  968. * \param SrcName is the source package name
  969. * \param SrcVersion is the source package version
  970. * \param DestDir The directory the file should be downloaded into.
  971. * Will be an autocreated (and cleaned up) temporary directory if not set.
  972. * \param DestFilename The filename the file should have in #DestDir
  973. * Defaults to sourcepackagename.changelog if not set.
  974. */
  975. pkgAcqChangelog(pkgAcquire * const Owner, pkgCache::RlsFileIterator const &Rls,
  976. char const * const Component, char const * const SrcName, char const * const SrcVersion,
  977. std::string const &DestDir="", std::string const &DestFilename="");
  978. /** \brief Create a new pkgAcqChangelog object.
  979. *
  980. * \param Owner The pkgAcquire object with which this object is
  981. * associated.
  982. * \param URI is to be used to get the changelog
  983. * \param SrcName is the source package name
  984. * \param SrcVersion is the source package version
  985. * \param DestDir The directory the file should be downloaded into.
  986. * Will be an autocreated (and cleaned up) temporary directory if not set.
  987. * \param DestFilename The filename the file should have in #DestDir
  988. * Defaults to sourcepackagename.changelog if not set.
  989. */
  990. pkgAcqChangelog(pkgAcquire * const Owner, std::string const &URI,
  991. char const * const SrcName, char const * const SrcVersion,
  992. std::string const &DestDir="", std::string const &DestFilename="");
  993. virtual ~pkgAcqChangelog();
  994. private:
  995. APT_HIDDEN void Init(std::string const &DestDir, std::string const &DestFilename);
  996. };
  997. /*}}}*/
  998. /** \brief Retrieve an arbitrary file to the current directory. {{{
  999. *
  1000. * The file is retrieved even if it is accessed via a URL type that
  1001. * normally is a NOP, such as "file". If the download fails, the
  1002. * partial file is renamed to get a ".FAILED" extension.
  1003. */
  1004. class pkgAcqFile : public pkgAcquire::Item
  1005. {
  1006. void * const d;
  1007. /** \brief How many times to retry the download, set from
  1008. * Acquire::Retries.
  1009. */
  1010. unsigned int Retries;
  1011. /** \brief Should this file be considered a index file */
  1012. bool IsIndexFile;
  1013. HashStringList const ExpectedHashes;
  1014. public:
  1015. virtual HashStringList GetExpectedHashes() const APT_OVERRIDE;
  1016. virtual bool HashesRequired() const APT_OVERRIDE;
  1017. // Specialized action members
  1018. virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  1019. virtual void Done(std::string const &Message, HashStringList const &CalcHashes,
  1020. pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  1021. virtual std::string DescURI() const APT_OVERRIDE {return Desc.URI;};
  1022. virtual std::string Custom600Headers() const APT_OVERRIDE;
  1023. /** \brief Create a new pkgAcqFile object.
  1024. *
  1025. * \param Owner The pkgAcquire object with which this object is
  1026. * associated.
  1027. *
  1028. * \param URI The URI to download.
  1029. *
  1030. * \param Hashes The hashsums of the file to download, if they are known;
  1031. * otherwise empty list.
  1032. *
  1033. * \param Size The size of the file to download, if it is known;
  1034. * otherwise 0.
  1035. *
  1036. * \param Desc A description of the file being downloaded.
  1037. *
  1038. * \param ShortDesc A brief description of the file being
  1039. * downloaded.
  1040. *
  1041. * \param DestDir The directory the file should be downloaded into.
  1042. *
  1043. * \param DestFilename The filename+path the file is downloaded to.
  1044. *
  1045. * \param IsIndexFile The file is considered a IndexFile and cache-control
  1046. * headers like "cache-control: max-age=0" are send
  1047. *
  1048. * If DestFilename is empty, download to DestDir/\<basename\> if
  1049. * DestDir is non-empty, $CWD/\<basename\> otherwise. If
  1050. * DestFilename is NOT empty, DestDir is ignored and DestFilename
  1051. * is the absolute name to which the file should be downloaded.
  1052. */
  1053. pkgAcqFile(pkgAcquire * const Owner, std::string const &URI, HashStringList const &Hashes, unsigned long long const Size,
  1054. std::string const &Desc, std::string const &ShortDesc,
  1055. std::string const &DestDir="", std::string const &DestFilename="",
  1056. bool const IsIndexFile=false);
  1057. virtual ~pkgAcqFile();
  1058. };
  1059. /*}}}*/
  1060. /** @} */
  1061. #endif