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