apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

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