acquire-item.h 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230
  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. /** \brief The priority of the item, used for queuing */
  264. int APT_HIDDEN Priority();
  265. protected:
  266. /** \brief The acquire object with which this item is associated. */
  267. pkgAcquire * const Owner;
  268. /** \brief The item that is currently being downloaded. */
  269. pkgAcquire::ItemDesc Desc;
  270. enum RenameOnErrorState {
  271. HashSumMismatch,
  272. SizeMismatch,
  273. InvalidFormat,
  274. SignatureError,
  275. NotClearsigned,
  276. MaximumSizeExceeded,
  277. PDiffError,
  278. };
  279. /** \brief Rename failed file and set error
  280. *
  281. * \param state respresenting the error we encountered
  282. */
  283. bool RenameOnError(RenameOnErrorState const state);
  284. /** \brief Insert this item into its owner's queue.
  285. *
  286. * The method is designed to check if the request would end
  287. * in an IMSHit and if it determines that it would, it isn't
  288. * queueing the Item and instead sets it to completion instantly.
  289. *
  290. * \param Item Metadata about this item (its URI and
  291. * description).
  292. * \return true if the item was inserted, false if IMSHit was detected
  293. */
  294. virtual bool QueueURI(ItemDesc &Item);
  295. /** \brief Remove this item from its owner's queue. */
  296. void Dequeue();
  297. /** \brief Rename a file without modifying its timestamp.
  298. *
  299. * Many item methods call this as their final action.
  300. *
  301. * \param From The file to be renamed.
  302. *
  303. * \param To The new name of \a From. If \a To exists it will be
  304. * overwritten. If \a From and \a To are equal nothing happens.
  305. */
  306. bool Rename(std::string const &From, std::string const &To);
  307. /** \brief Get the full pathname of the final file for the current URI */
  308. virtual std::string GetFinalFilename() const;
  309. private:
  310. class Private;
  311. Private * const d;
  312. friend class pkgAcqMetaBase;
  313. friend class pkgAcqMetaClearSig;
  314. };
  315. /*}}}*/
  316. class APT_HIDDEN pkgAcqTransactionItem: public pkgAcquire::Item /*{{{*/
  317. /** \brief baseclass for the indexes files to manage them all together */
  318. {
  319. void * const d;
  320. protected:
  321. HashStringList GetExpectedHashesFor(std::string const &MetaKey) const;
  322. bool QueueURI(pkgAcquire::ItemDesc &Item) APT_OVERRIDE;
  323. public:
  324. IndexTarget const Target;
  325. /** \brief storge name until a transaction is finished */
  326. std::string PartialFile;
  327. /** \brief TransactionManager */
  328. pkgAcqMetaClearSig * const TransactionManager;
  329. enum TransactionStates {
  330. TransactionStarted,
  331. TransactionCommit,
  332. TransactionAbort,
  333. };
  334. virtual bool TransactionState(TransactionStates const state);
  335. virtual std::string DescURI() const APT_OVERRIDE { return Target.URI; }
  336. virtual HashStringList GetExpectedHashes() const APT_OVERRIDE;
  337. virtual std::string GetMetaKey() const;
  338. virtual bool HashesRequired() const APT_OVERRIDE;
  339. pkgAcqTransactionItem(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager, IndexTarget const &Target) APT_NONNULL(2, 3);
  340. virtual ~pkgAcqTransactionItem();
  341. friend class pkgAcqMetaBase;
  342. friend class pkgAcqMetaClearSig;
  343. };
  344. /*}}}*/
  345. class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem /*{{{*/
  346. /** \brief the manager of a transaction */
  347. {
  348. void * const d;
  349. protected:
  350. std::vector<pkgAcqTransactionItem*> Transaction;
  351. /** \brief If \b true, the index's signature is currently being verified.
  352. */
  353. bool AuthPass;
  354. /** \brief Called when a file is finished being retrieved.
  355. *
  356. * If the file was not downloaded to DestFile, a copy process is
  357. * set up to copy it to DestFile; otherwise, Complete is set to \b
  358. * true and the file is moved to its final location.
  359. *
  360. * \param Message The message block received from the fetch
  361. * subprocess.
  362. */
  363. bool CheckDownloadDone(pkgAcqTransactionItem * const I, const std::string &Message, HashStringList const &Hashes) const;
  364. /** \brief Queue the downloaded Signature for verification */
  365. void QueueForSignatureVerify(pkgAcqTransactionItem * const I, std::string const &File, std::string const &Signature);
  366. virtual std::string Custom600Headers() const APT_OVERRIDE;
  367. /** \brief Called when authentication succeeded.
  368. *
  369. * Sanity-checks the authenticated file, queues up the individual
  370. * index files for download, and saves the signature in the lists
  371. * directory next to the authenticated list file.
  372. *
  373. * \param Message The message block received from the fetch
  374. * subprocess.
  375. */
  376. bool CheckAuthDone(std::string const &Message);
  377. /** Check if the current item should fail at this point */
  378. bool CheckStopAuthentication(pkgAcquire::Item * const I, const std::string &Message);
  379. /** \brief Check that the release file is a release file for the
  380. * correct distribution.
  381. *
  382. * \return \b true if no fatal errors were encountered.
  383. */
  384. bool VerifyVendor(std::string const &Message);
  385. virtual bool TransactionState(TransactionStates const state) APT_OVERRIDE;
  386. public:
  387. // This refers more to the Transaction-Manager than the actual file
  388. bool IMSHit;
  389. TransactionStates State;
  390. std::string BaseURI;
  391. virtual bool QueueURI(pkgAcquire::ItemDesc &Item) APT_OVERRIDE;
  392. virtual HashStringList GetExpectedHashes() const APT_OVERRIDE;
  393. virtual bool HashesRequired() const APT_OVERRIDE;
  394. // transaction code
  395. void Add(pkgAcqTransactionItem * const I);
  396. void AbortTransaction();
  397. bool TransactionHasError() const;
  398. void CommitTransaction();
  399. /** \brief Stage (queue) a copy action when the transaction is committed
  400. */
  401. void TransactionStageCopy(pkgAcqTransactionItem * const I,
  402. const std::string &From,
  403. const std::string &To);
  404. /** \brief Stage (queue) a removal action when the transaction is committed
  405. */
  406. void TransactionStageRemoval(pkgAcqTransactionItem * const I, const std::string &FinalFile);
  407. /** \brief Get the full pathname of the final file for the current URI */
  408. virtual std::string GetFinalFilename() const APT_OVERRIDE;
  409. pkgAcqMetaBase(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
  410. IndexTarget const &DataTarget) APT_NONNULL(2, 3);
  411. virtual ~pkgAcqMetaBase();
  412. };
  413. /*}}}*/
  414. /** \brief An item that is responsible for downloading the meta-index {{{
  415. * file (i.e., Release) itself and verifying its signature.
  416. *
  417. * Once the download and verification are complete, the downloads of
  418. * the individual index files are queued up using pkgAcqDiffIndex.
  419. * If the meta-index file had a valid signature, the expected hashsums
  420. * of the index files will be the md5sums listed in the meta-index;
  421. * otherwise, the expected hashsums will be "" (causing the
  422. * authentication of the index files to be bypassed).
  423. */
  424. class APT_HIDDEN pkgAcqMetaIndex : public pkgAcqMetaBase
  425. {
  426. void * const d;
  427. protected:
  428. IndexTarget const DetachedSigTarget;
  429. /** \brief delayed constructor */
  430. void Init(std::string const &URIDesc, std::string const &ShortDesc);
  431. public:
  432. virtual std::string DescURI() const APT_OVERRIDE;
  433. // Specialized action members
  434. virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  435. virtual void Done(std::string const &Message, HashStringList const &Hashes,
  436. pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  437. /** \brief Create a new pkgAcqMetaIndex. */
  438. pkgAcqMetaIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
  439. IndexTarget const &DataTarget, IndexTarget const &DetachedSigTarget) APT_NONNULL(2, 3);
  440. virtual ~pkgAcqMetaIndex();
  441. friend class pkgAcqMetaSig;
  442. };
  443. /*}}}*/
  444. /** \brief An acquire item that downloads the detached signature {{{
  445. * of a meta-index (Release) file, then queues up the release
  446. * file itself.
  447. *
  448. * \todo Why protected members?
  449. *
  450. * \sa pkgAcqMetaIndex
  451. */
  452. class APT_HIDDEN pkgAcqMetaSig : public pkgAcqTransactionItem
  453. {
  454. void * const d;
  455. pkgAcqMetaIndex * const MetaIndex;
  456. /** \brief The file we use to verify the MetaIndexFile with (not always set!) */
  457. std::string MetaIndexFileSignature;
  458. protected:
  459. /** \brief Get the full pathname of the final file for the current URI */
  460. virtual std::string GetFinalFilename() const APT_OVERRIDE;
  461. public:
  462. virtual bool HashesRequired() const APT_OVERRIDE { return false; }
  463. // Specialized action members
  464. virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  465. virtual void Done(std::string const &Message, HashStringList const &Hashes,
  466. pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  467. virtual std::string Custom600Headers() const APT_OVERRIDE;
  468. /** \brief Create a new pkgAcqMetaSig. */
  469. pkgAcqMetaSig(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
  470. IndexTarget const &Target, pkgAcqMetaIndex * const MetaIndex) APT_NONNULL(2, 3, 5);
  471. virtual ~pkgAcqMetaSig();
  472. };
  473. /*}}}*/
  474. /** \brief An item repsonsible for downloading clearsigned metaindexes {{{*/
  475. class APT_HIDDEN pkgAcqMetaClearSig : public pkgAcqMetaIndex
  476. {
  477. void * const d;
  478. IndexTarget const DetachedDataTarget;
  479. public:
  480. /** \brief A package-system-specific parser for the meta-index file. */
  481. metaIndex *MetaIndexParser;
  482. metaIndex *LastMetaIndexParser;
  483. virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  484. virtual std::string Custom600Headers() const APT_OVERRIDE;
  485. virtual bool VerifyDone(std::string const &Message, pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  486. virtual void Done(std::string const &Message, HashStringList const &Hashes,
  487. pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  488. virtual void Finished() APT_OVERRIDE;
  489. /** \brief Starts downloading the individual index files.
  490. *
  491. * \param verify If \b true, only indices whose expected hashsum
  492. * can be determined from the meta-index will be downloaded, and
  493. * the hashsums of indices will be checked (reporting
  494. * #StatAuthError if there is a mismatch). If verify is \b false,
  495. * no hashsum checking will be performed.
  496. */
  497. void QueueIndexes(bool const verify);
  498. /** \brief Create a new pkgAcqMetaClearSig. */
  499. pkgAcqMetaClearSig(pkgAcquire * const Owner,
  500. IndexTarget const &ClearsignedTarget,
  501. IndexTarget const &DetachedDataTarget,
  502. IndexTarget const &DetachedSigTarget,
  503. metaIndex * const MetaIndexParser);
  504. virtual ~pkgAcqMetaClearSig();
  505. };
  506. /*}}}*/
  507. /** \brief Common base class for all classes that deal with fetching indexes {{{*/
  508. class APT_HIDDEN pkgAcqBaseIndex : public pkgAcqTransactionItem
  509. {
  510. void * const d;
  511. public:
  512. /** \brief Get the full pathname of the final file for the current URI */
  513. virtual std::string GetFinalFilename() const APT_OVERRIDE;
  514. virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  515. pkgAcqBaseIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
  516. IndexTarget const &Target) APT_NONNULL(2, 3);
  517. virtual ~pkgAcqBaseIndex();
  518. };
  519. /*}}}*/
  520. /** \brief An acquire item that is responsible for fetching an index {{{
  521. * file (e.g., Packages or Sources).
  522. *
  523. * \sa pkgAcqDiffIndex, pkgAcqIndexDiffs, pkgAcqIndexTrans
  524. *
  525. * \todo Why does pkgAcqIndex have protected members?
  526. */
  527. class APT_HIDDEN pkgAcqIndex : public pkgAcqBaseIndex
  528. {
  529. void * const d;
  530. protected:
  531. /** \brief The stages the method goes through
  532. *
  533. * The method first downloads the indexfile, then its decompressed (or
  534. * copied) and verified
  535. */
  536. enum AllStages {
  537. STAGE_DOWNLOAD,
  538. STAGE_DECOMPRESS_AND_VERIFY,
  539. };
  540. AllStages Stage;
  541. /** \brief Handle what needs to be done when the download is done */
  542. void StageDownloadDone(std::string const &Message);
  543. /** \brief Handle what needs to be done when the decompression/copy is
  544. * done
  545. */
  546. void StageDecompressDone();
  547. /** \brief If \b set, this partially downloaded file will be
  548. * removed when the download completes.
  549. */
  550. std::string EraseFileName;
  551. /** \brief The compression-related file extensions that are being
  552. * added to the downloaded file one by one if first fails (e.g., "gz bz2").
  553. */
  554. std::string CompressionExtensions;
  555. /** \brief The actual compression extension currently used */
  556. std::string CurrentCompressionExtension;
  557. /** \brief Do the changes needed to fetch via AptByHash (if needed) */
  558. void InitByHashIfNeeded();
  559. /** \brief Get the full pathname of the final file for the current URI */
  560. virtual std::string GetFinalFilename() const APT_OVERRIDE;
  561. virtual bool TransactionState(TransactionStates const state) APT_OVERRIDE;
  562. public:
  563. // Specialized action members
  564. virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  565. virtual void Done(std::string const &Message, HashStringList const &Hashes,
  566. pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  567. virtual std::string Custom600Headers() const APT_OVERRIDE;
  568. virtual std::string DescURI() const APT_OVERRIDE {return Desc.URI;};
  569. virtual std::string GetMetaKey() const APT_OVERRIDE;
  570. pkgAcqIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
  571. IndexTarget const &Target, bool const Derived = false) APT_NONNULL(2, 3);
  572. virtual ~pkgAcqIndex();
  573. protected:
  574. APT_HIDDEN void Init(std::string const &URI, std::string const &URIDesc,
  575. std::string const &ShortDesc);
  576. APT_HIDDEN bool CommonFailed(std::string const &TargetURI, std::string const TargetDesc,
  577. std::string const &Message, pkgAcquire::MethodConfig const * const Cnf);
  578. };
  579. /*}}}*/
  580. /** \brief An item that is responsible for fetching an index file of {{{
  581. * package list diffs and starting the package list's download.
  582. *
  583. * This item downloads the Index file and parses it, then enqueues
  584. * additional downloads of either the individual patches (using
  585. * pkgAcqIndexDiffs) or the entire Packages file (using pkgAcqIndex).
  586. *
  587. * \sa pkgAcqIndexDiffs, pkgAcqIndex
  588. */
  589. class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqIndex
  590. {
  591. void * const d;
  592. std::vector<pkgAcqIndexMergeDiffs*> * diffs;
  593. protected:
  594. /** \brief If \b true, debugging information will be written to std::clog. */
  595. bool Debug;
  596. /** \brief A description of the Packages file (stored in
  597. * pkgAcquire::ItemDesc::Description).
  598. */
  599. std::string Description;
  600. /** \brief Get the full pathname of the final file for the current URI */
  601. virtual std::string GetFinalFilename() const APT_OVERRIDE;
  602. virtual bool QueueURI(pkgAcquire::ItemDesc &Item) APT_OVERRIDE;
  603. virtual bool TransactionState(TransactionStates const state) APT_OVERRIDE;
  604. public:
  605. // Specialized action members
  606. virtual void Failed(std::string const &Message, pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  607. virtual void Done(std::string const &Message, HashStringList const &Hashes,
  608. pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  609. virtual std::string DescURI() const APT_OVERRIDE {return Target.URI + "Index";};
  610. virtual std::string GetMetaKey() const APT_OVERRIDE;
  611. /** \brief Parse the Index file for a set of Packages diffs.
  612. *
  613. * Parses the Index file and creates additional download items as
  614. * necessary.
  615. *
  616. * \param IndexDiffFile The name of the Index file.
  617. *
  618. * \return \b true if the Index file was successfully parsed, \b
  619. * false otherwise.
  620. */
  621. bool ParseDiffIndex(std::string const &IndexDiffFile);
  622. /** \brief Create a new pkgAcqDiffIndex.
  623. *
  624. * \param Owner The Acquire object that owns this item.
  625. *
  626. * \param URI The URI of the list file to download.
  627. *
  628. * \param URIDesc A long description of the list file to download.
  629. *
  630. * \param ShortDesc A short description of the list file to download.
  631. */
  632. pkgAcqDiffIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
  633. IndexTarget const &Target) APT_NONNULL(2, 3);
  634. virtual ~pkgAcqDiffIndex();
  635. private:
  636. APT_HIDDEN void QueueOnIMSHit() const;
  637. };
  638. /*}}}*/
  639. struct APT_HIDDEN DiffInfo { /*{{{*/
  640. /** The filename of the diff. */
  641. std::string file;
  642. /** The hashes of the file after the diff is applied */
  643. HashStringList result_hashes;
  644. /** The hashes of the diff */
  645. HashStringList patch_hashes;
  646. /** The hashes of the compressed diff */
  647. HashStringList download_hashes;
  648. };
  649. /*}}}*/
  650. /** \brief An item that is responsible for fetching client-merge patches {{{
  651. * that need to be applied to a given package index file.
  652. *
  653. * Instead of downloading and applying each patch one by one like its
  654. * sister #pkgAcqIndexDiffs this class will download all patches at once
  655. * and call rred with all the patches downloaded once. Rred will then
  656. * merge and apply them in one go, which should be a lot faster – but is
  657. * incompatible with server-based merges of patches like reprepro can do.
  658. *
  659. * \sa pkgAcqDiffIndex, pkgAcqIndex
  660. */
  661. class APT_HIDDEN pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex
  662. {
  663. std::string const indexURI;
  664. protected:
  665. /** \brief If \b true, debugging output will be written to
  666. * std::clog.
  667. */
  668. bool Debug;
  669. /** \brief description of the file being downloaded. */
  670. std::string Description;
  671. /** \brief information about the current patch */
  672. struct DiffInfo const patch;
  673. /** \brief list of all download items for the patches */
  674. std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches;
  675. /** The current status of this patch. */
  676. enum DiffState
  677. {
  678. /** \brief The diff is currently being fetched. */
  679. StateFetchDiff,
  680. /** \brief The diff is currently being applied. */
  681. StateApplyDiff,
  682. /** \brief the work with this diff is done */
  683. StateDoneDiff,
  684. /** \brief something bad happened and fallback was triggered */
  685. StateErrorDiff
  686. } State;
  687. public:
  688. /** \brief Called when the patch file failed to be downloaded.
  689. *
  690. * This method will fall back to downloading the whole index file
  691. * outright; its arguments are ignored.
  692. */
  693. virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  694. virtual void Done(std::string const &Message, HashStringList const &Hashes,
  695. pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  696. virtual std::string Custom600Headers() const APT_OVERRIDE;
  697. virtual std::string DescURI() const APT_OVERRIDE {return Target.URI + "Index";};
  698. virtual HashStringList GetExpectedHashes() const APT_OVERRIDE;
  699. virtual bool HashesRequired() const APT_OVERRIDE;
  700. /** \brief Create an index merge-diff item.
  701. *
  702. * \param Owner The pkgAcquire object that owns this item.
  703. * \param TransactionManager responsible for this item
  704. * \param Target we intend to built via pdiff patching
  705. * \param baseURI is the URI used for the Index, but stripped down to Target
  706. * \param DiffInfo of the patch in question
  707. * \param patch contains infos about the patch this item is supposed
  708. * to download which were read from the index
  709. * \param allPatches contains all related items so that each item can
  710. * check if it was the last one to complete the download step
  711. */
  712. pkgAcqIndexMergeDiffs(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
  713. IndexTarget const &Target, std::string const &indexUsedMirror,
  714. std::string const &indexURI, DiffInfo const &patch,
  715. std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches) APT_NONNULL(2, 3, 8);
  716. virtual ~pkgAcqIndexMergeDiffs();
  717. };
  718. /*}}}*/
  719. /** \brief An item that is responsible for fetching server-merge patches {{{
  720. * that need to be applied to a given package index file.
  721. *
  722. * After downloading and applying a single patch, this item will
  723. * enqueue a new pkgAcqIndexDiffs to download and apply the remaining
  724. * patches. If no patch can be found that applies to an intermediate
  725. * file or if one of the patches cannot be downloaded, falls back to
  726. * downloading the entire package index file using pkgAcqIndex.
  727. *
  728. * \sa pkgAcqDiffIndex, pkgAcqIndex
  729. */
  730. class APT_HIDDEN pkgAcqIndexDiffs : public pkgAcqBaseIndex
  731. {
  732. std::string const indexURI;
  733. private:
  734. /** \brief Queue up the next diff download.
  735. *
  736. * Search for the next available diff that applies to the file
  737. * that currently exists on disk, and enqueue it by calling
  738. * QueueURI().
  739. *
  740. * \return \b true if an applicable diff was found, \b false
  741. * otherwise.
  742. */
  743. APT_HIDDEN bool QueueNextDiff();
  744. /** \brief Handle tasks that must be performed after the item
  745. * finishes downloading.
  746. *
  747. * Dequeues the item and checks the resulting file's hashsums
  748. * against ExpectedHashes after the last patch was applied.
  749. * There is no need to check the md5/sha1 after a "normal"
  750. * patch because QueueNextDiff() will check the sha1 later.
  751. *
  752. * \param allDone If \b true, the file was entirely reconstructed,
  753. * and its md5sum is verified.
  754. */
  755. APT_HIDDEN void Finish(bool const allDone=false);
  756. protected:
  757. /** \brief If \b true, debugging output will be written to
  758. * std::clog.
  759. */
  760. bool Debug;
  761. /** A description of the file being downloaded. */
  762. std::string Description;
  763. /** The patches that remain to be downloaded, including the patch
  764. * being downloaded right now. This list should be ordered so
  765. * that each diff appears before any diff that depends on it.
  766. *
  767. * \todo These are indexed by sha1sum; why not use some sort of
  768. * dictionary instead of relying on ordering and stripping them
  769. * off the front?
  770. */
  771. std::vector<DiffInfo> available_patches;
  772. /** The current status of this patch. */
  773. enum DiffState
  774. {
  775. /** \brief The diff is currently being fetched. */
  776. StateFetchDiff,
  777. /** \brief The diff is currently being applied. */
  778. StateApplyDiff
  779. } State;
  780. public:
  781. /** \brief Called when the patch file failed to be downloaded.
  782. *
  783. * This method will fall back to downloading the whole index file
  784. * outright; its arguments are ignored.
  785. */
  786. virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  787. virtual void Done(std::string const &Message, HashStringList const &Hashes,
  788. pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  789. virtual std::string Custom600Headers() const APT_OVERRIDE;
  790. virtual std::string DescURI() const APT_OVERRIDE {return Target.URI + "IndexDiffs";};
  791. virtual HashStringList GetExpectedHashes() const APT_OVERRIDE;
  792. virtual bool HashesRequired() const APT_OVERRIDE;
  793. /** \brief Create an index diff item.
  794. *
  795. * After filling in its basic fields, this invokes Finish(true) if
  796. * \a diffs is empty, or QueueNextDiff() otherwise.
  797. *
  798. * \param Owner The pkgAcquire object that owns this item.
  799. * \param TransactionManager responsible for this item
  800. * \param Target we want to built via pdiff patching
  801. * \param baseURI is the URI used for the Index, but stripped down to Target
  802. * \param diffs The remaining diffs from the index of diffs. They
  803. * should be ordered so that each diff appears before any diff
  804. * that depends on it.
  805. */
  806. pkgAcqIndexDiffs(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
  807. IndexTarget const &Target,
  808. std::string const &indexUsedMirror, std::string const &indexURI,
  809. std::vector<DiffInfo> const &diffs=std::vector<DiffInfo>()) APT_NONNULL(2, 3);
  810. virtual ~pkgAcqIndexDiffs();
  811. };
  812. /*}}}*/
  813. /** \brief An item that is responsible for fetching a package file. {{{
  814. *
  815. * If the package file already exists in the cache, nothing will be
  816. * done.
  817. */
  818. class pkgAcqArchive : public pkgAcquire::Item
  819. {
  820. void * const d;
  821. bool LocalSource;
  822. HashStringList ExpectedHashes;
  823. protected:
  824. /** \brief The package version being fetched. */
  825. pkgCache::VerIterator Version;
  826. /** \brief The list of sources from which to pick archives to
  827. * download this package from.
  828. */
  829. pkgSourceList *Sources;
  830. /** \brief A package records object, used to look up the file
  831. * corresponding to each version of the package.
  832. */
  833. pkgRecords *Recs;
  834. /** \brief A location in which the actual filename of the package
  835. * should be stored.
  836. */
  837. std::string &StoreFilename;
  838. /** \brief The next file for this version to try to download. */
  839. pkgCache::VerFileIterator Vf;
  840. /** \brief How many (more) times to try to find a new source from
  841. * which to download this package version if it fails.
  842. *
  843. * Set from Acquire::Retries.
  844. */
  845. unsigned int Retries;
  846. /** \brief \b true if this version file is being downloaded from a
  847. * trusted source.
  848. */
  849. bool Trusted;
  850. /** \brief Queue up the next available file for this version. */
  851. bool QueueNext();
  852. /** \brief Get the full pathname of the final file for the current URI */
  853. virtual std::string GetFinalFilename() const APT_OVERRIDE;
  854. public:
  855. virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  856. virtual void Done(std::string const &Message, HashStringList const &Hashes,
  857. pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  858. virtual std::string DescURI() const APT_OVERRIDE;
  859. virtual std::string ShortDesc() const APT_OVERRIDE;
  860. virtual void Finished() APT_OVERRIDE;
  861. virtual bool IsTrusted() const APT_OVERRIDE;
  862. virtual HashStringList GetExpectedHashes() const APT_OVERRIDE;
  863. virtual bool HashesRequired() const APT_OVERRIDE;
  864. /** \brief Create a new pkgAcqArchive.
  865. *
  866. * \param Owner The pkgAcquire object with which this item is
  867. * associated.
  868. *
  869. * \param Sources The sources from which to download version
  870. * files.
  871. *
  872. * \param Recs A package records object, used to look up the file
  873. * corresponding to each version of the package.
  874. *
  875. * \param Version The package version to download.
  876. *
  877. * \param[out] StoreFilename A location in which the actual filename of
  878. * the package should be stored. It will be set to a guessed
  879. * basename in the constructor, and filled in with a fully
  880. * qualified filename once the download finishes.
  881. */
  882. pkgAcqArchive(pkgAcquire * const Owner,pkgSourceList * const Sources,
  883. pkgRecords * const Recs,pkgCache::VerIterator const &Version,
  884. std::string &StoreFilename);
  885. virtual ~pkgAcqArchive();
  886. };
  887. /*}}}*/
  888. /** \brief Retrieve the changelog for the given version {{{
  889. *
  890. * Downloads the changelog to a temporary file it will also remove again
  891. * while it is deconstructed or downloads it to a named location.
  892. */
  893. class pkgAcqChangelog : public pkgAcquire::Item
  894. {
  895. class Private;
  896. Private * const d;
  897. std::string TemporaryDirectory;
  898. std::string const SrcName;
  899. std::string const SrcVersion;
  900. public:
  901. // we will never have hashes for changelogs.
  902. // If you need verified ones, download the deb and extract the changelog.
  903. virtual HashStringList GetExpectedHashes() const APT_OVERRIDE { return HashStringList(); }
  904. virtual bool HashesRequired() const APT_OVERRIDE { return false; }
  905. // Specialized action members
  906. virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  907. virtual void Done(std::string const &Message, HashStringList const &CalcHashes,
  908. pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  909. virtual std::string DescURI() const APT_OVERRIDE {return Desc.URI;};
  910. /** returns the URI to the changelog of this version
  911. *
  912. * @param Ver is the version to get the changelog for
  913. * @return the URI which will be used to acquire the changelog
  914. */
  915. static std::string URI(pkgCache::VerIterator const &Ver);
  916. /** returns the URI to the changelog of this version
  917. *
  918. * \param Rls is the Release file the package comes from
  919. * \param Component in which the package resides, can be empty
  920. * \param SrcName is the source package name
  921. * \param SrcVersion is the source package version
  922. * @return the URI which will be used to acquire the changelog
  923. */
  924. static std::string URI(pkgCache::RlsFileIterator const &Rls,
  925. char const * const Component, char const * const SrcName,
  926. char const * const SrcVersion);
  927. /** returns the URI to the changelog of this version
  928. *
  929. * \param Template URI where @CHANGEPATH@ has to be filled in
  930. * \param Component in which the package resides, can be empty
  931. * \param SrcName is the source package name
  932. * \param SrcVersion is the source package version
  933. * @return the URI which will be used to acquire the changelog
  934. */
  935. static std::string URI(std::string const &Template,
  936. char const * const Component, char const * const SrcName,
  937. char const * const SrcVersion);
  938. /** returns the URI template for this release file
  939. *
  940. * \param Rls is a Release file
  941. * @return the URI template to use for this release file
  942. */
  943. static std::string URITemplate(pkgCache::RlsFileIterator const &Rls);
  944. /** \brief Create a new pkgAcqChangelog object.
  945. *
  946. * \param Owner The pkgAcquire object with which this object is
  947. * associated.
  948. * \param Ver is the version to get the changelog for
  949. * \param DestDir The directory the file should be downloaded into.
  950. * Will be an autocreated (and cleaned up) temporary directory if not set.
  951. * \param DestFilename The filename the file should have in #DestDir
  952. * Defaults to sourcepackagename.changelog if not set.
  953. */
  954. pkgAcqChangelog(pkgAcquire * const Owner, pkgCache::VerIterator const &Ver,
  955. std::string const &DestDir="", std::string const &DestFilename="");
  956. /** \brief Create a new pkgAcqChangelog object.
  957. *
  958. * \param Owner The pkgAcquire object with which this object is
  959. * associated.
  960. * \param Rls is the Release file the package comes from
  961. * \param Component in which the package resides, can be empty
  962. * \param SrcName is the source package name
  963. * \param SrcVersion is the source package version
  964. * \param DestDir The directory the file should be downloaded into.
  965. * Will be an autocreated (and cleaned up) temporary directory if not set.
  966. * \param DestFilename The filename the file should have in #DestDir
  967. * Defaults to sourcepackagename.changelog if not set.
  968. */
  969. pkgAcqChangelog(pkgAcquire * const Owner, pkgCache::RlsFileIterator const &Rls,
  970. char const * const Component, char const * const SrcName, char const * const SrcVersion,
  971. std::string const &DestDir="", std::string const &DestFilename="");
  972. /** \brief Create a new pkgAcqChangelog object.
  973. *
  974. * \param Owner The pkgAcquire object with which this object is
  975. * associated.
  976. * \param URI is to be used to get the changelog
  977. * \param SrcName is the source package name
  978. * \param SrcVersion is the source package version
  979. * \param DestDir The directory the file should be downloaded into.
  980. * Will be an autocreated (and cleaned up) temporary directory if not set.
  981. * \param DestFilename The filename the file should have in #DestDir
  982. * Defaults to sourcepackagename.changelog if not set.
  983. */
  984. pkgAcqChangelog(pkgAcquire * const Owner, std::string const &URI,
  985. char const * const SrcName, char const * const SrcVersion,
  986. std::string const &DestDir="", std::string const &DestFilename="");
  987. virtual ~pkgAcqChangelog();
  988. private:
  989. APT_HIDDEN void Init(std::string const &DestDir, std::string const &DestFilename);
  990. };
  991. /*}}}*/
  992. /** \brief Retrieve an arbitrary file to the current directory. {{{
  993. *
  994. * The file is retrieved even if it is accessed via a URL type that
  995. * normally is a NOP, such as "file". If the download fails, the
  996. * partial file is renamed to get a ".FAILED" extension.
  997. */
  998. class pkgAcqFile : public pkgAcquire::Item
  999. {
  1000. void * const d;
  1001. /** \brief How many times to retry the download, set from
  1002. * Acquire::Retries.
  1003. */
  1004. unsigned int Retries;
  1005. /** \brief Should this file be considered a index file */
  1006. bool IsIndexFile;
  1007. HashStringList const ExpectedHashes;
  1008. public:
  1009. virtual HashStringList GetExpectedHashes() const APT_OVERRIDE;
  1010. virtual bool HashesRequired() const APT_OVERRIDE;
  1011. // Specialized action members
  1012. virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  1013. virtual void Done(std::string const &Message, HashStringList const &CalcHashes,
  1014. pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
  1015. virtual std::string DescURI() const APT_OVERRIDE {return Desc.URI;};
  1016. virtual std::string Custom600Headers() const APT_OVERRIDE;
  1017. /** \brief Create a new pkgAcqFile object.
  1018. *
  1019. * \param Owner The pkgAcquire object with which this object is
  1020. * associated.
  1021. *
  1022. * \param URI The URI to download.
  1023. *
  1024. * \param Hashes The hashsums of the file to download, if they are known;
  1025. * otherwise empty list.
  1026. *
  1027. * \param Size The size of the file to download, if it is known;
  1028. * otherwise 0.
  1029. *
  1030. * \param Desc A description of the file being downloaded.
  1031. *
  1032. * \param ShortDesc A brief description of the file being
  1033. * downloaded.
  1034. *
  1035. * \param DestDir The directory the file should be downloaded into.
  1036. *
  1037. * \param DestFilename The filename+path the file is downloaded to.
  1038. *
  1039. * \param IsIndexFile The file is considered a IndexFile and cache-control
  1040. * headers like "cache-control: max-age=0" are send
  1041. *
  1042. * If DestFilename is empty, download to DestDir/\<basename\> if
  1043. * DestDir is non-empty, $CWD/\<basename\> otherwise. If
  1044. * DestFilename is NOT empty, DestDir is ignored and DestFilename
  1045. * is the absolute name to which the file should be downloaded.
  1046. */
  1047. pkgAcqFile(pkgAcquire * const Owner, std::string const &URI, HashStringList const &Hashes, unsigned long long const Size,
  1048. std::string const &Desc, std::string const &ShortDesc,
  1049. std::string const &DestDir="", std::string const &DestFilename="",
  1050. bool const IsIndexFile=false);
  1051. virtual ~pkgAcqFile();
  1052. };
  1053. /*}}}*/
  1054. /** @} */
  1055. #endif