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