65#ifndef PKGLIB_ACQUIRE_H
66#define PKGLIB_ACQUIRE_H
68#include <apt-pkg/hashes.h>
69#include <apt-pkg/macros.h>
70#include <apt-pkg/weakptr.h>
77#include <sys/select.h>
97 using clock = std::chrono::steady_clock;
99 using time_point = std::chrono::time_point<clock>;
116 typedef std::vector<Item *>::iterator ItemIterator;
117 typedef std::vector<Item *>::const_iterator ItemCIterator;
171 QueueAccess} QueueMode;
179 void Add(Item *Item);
182 void Remove(Item *Item);
185 void Add(Worker *Work);
188 void Remove(Worker *Work);
196 void Enqueue(ItemDesc &Item);
199 void Dequeue(Item *Item);
211 std::string QueueName(std::string
URI,MethodConfig
const *&Config);
227 virtual void SetFds(
int &Fd,fd_set *RSet,fd_set *WSet);
241 virtual bool RunFds(fd_set *RSet,fd_set *WSet);
259 MethodConfig *GetConfig(std::string Access);
285 RunResult Run(
int PulseInterval=500000);
303 Worker *WorkerStep(Worker *I) APT_PURE;
307 inline ItemCIterator ItemsBegin()
const {
return Items.begin();};
310 inline ItemIterator
ItemsEnd() {
return Items.end();};
311 inline ItemCIterator ItemsEnd()
const {
return Items.end();};
320 UriIterator UriBegin();
322 UriIterator UriEnd();
332 bool Clean(std::string Dir);
340 bool CleanLists(std::string
const &Dir);
345 unsigned long long TotalNeeded();
350 unsigned long long FetchNeeded();
355 unsigned long long PartialPresent();
366 bool GetLock(std::string
const &Lock);
379 APT_HIDDEN
static std::string URIEncode(std::string
const &part);
382 APT_HIDDEN
void Initialize();
409 friend class pkgAcquire::UriIterator;
410 friend class pkgAcquire::Worker;
434 unsigned long long CurrentSize = 0;
439 unsigned long long TotalSize = 0;
444 unsigned long long ResumePoint = 0;
446 typedef std::vector<Item*>::const_iterator owner_iterator;
451 void operator =(pkgAcquire::ItemDesc
const &I)
454 Description = I.Description;
455 ShortDesc = I.ShortDesc;
457 Owners.push_back(I.Owner);
612 pkgAcquire::Queue *CurQ;
614 pkgAcquire::Queue::QItem *CurItem;
618 inline void operator ++() {operator ++(0);};
620 void operator ++(
int)
622 CurItem = CurItem->Next;
623 while (CurItem == 0 && CurQ != 0)
625 CurItem = CurQ->Items;
630 inline pkgAcquire::Queue::QItem
const *operator ->()
const {
return CurItem;};
631 inline bool operator !=(UriIterator
const &rhs)
const {
return rhs.CurQ != CurQ || rhs.CurItem != CurItem;};
632 inline bool operator ==(UriIterator
const &rhs)
const {
return rhs.CurQ == CurQ && rhs.CurItem == CurItem;};
639 virtual ~UriIterator();
698 APT_HIDDEN
bool GetAuxRequests()
const;
699 APT_HIDDEN
void SetAuxRequests(
bool const value);
700 APT_HIDDEN
bool GetSendURIEncoded()
const;
701 APT_HIDDEN
void SetSendURIEncoded(
bool const value);
703 virtual ~MethodConfig();
721 struct timeval StartTime;
790 virtual void Fetched(
unsigned long long Size,
unsigned long long ResumePoint);
809 virtual bool MediaChange(std::string Media,std::string Drive) = 0;
836 virtual bool ReleaseInfoChanges(
metaIndex const *
const LastRelease,
metaIndex const *
const CurrentRelease, std::vector<ReleaseInfoChange> &&Changes);
837 APT_HIDDEN
static bool ReleaseInfoChangesAsGlobalErrors(std::vector<ReleaseInfoChange> &&Changes);
844 virtual void IMSHit(pkgAcquire::ItemDesc &) {};
847 virtual void Fetch(pkgAcquire::ItemDesc &) {};
850 virtual void Done(pkgAcquire::ItemDesc &) {};
855 virtual void Fail(pkgAcquire::ItemDesc &) {};
870 virtual void Start();
A monitor object for downloads controlled by the pkgAcquire class. {{{.
Definition acquire.h:711
virtual void IMSHit(pkgAcquire::ItemDesc &)
Invoked when an item is confirmed to be up-to-date.
Definition acquire.h:844
unsigned long long ElapsedTime
The amount of time that has elapsed since the download started.
Definition acquire.h:753
double Percent
The estimated percentage of the download (0-100)
Definition acquire.h:767
virtual void Fail(pkgAcquire::ItemDesc &)
Invoked when the process of fetching an item encounters a fatal error.
Definition acquire.h:855
virtual void Done(pkgAcquire::ItemDesc &)
Invoked when an item is successfully and completely fetched.
Definition acquire.h:850
virtual bool MediaChange(std::string Media, std::string Drive)=0
Invoked when the user should be prompted to change the inserted removable media.
virtual void Fetch(pkgAcquire::ItemDesc &)
Invoked when some of an item's data is fetched.
Definition acquire.h:847
unsigned long long FetchedBytes
The total number of bytes accounted for by items that were successfully fetched.
Definition acquire.h:748
bool Update
If true, the download scheduler should call Pulse() at the next available opportunity.
Definition acquire.h:774
unsigned long long CurrentBytes
The number of bytes fetched as of the most recent call to pkgAcquireStatus::Pulse,...
Definition acquire.h:736
bool MorePulses
If true, extra Pulse() invocations will be performed.
Definition acquire.h:782
unsigned long CurrentItems
The number of items that have been successfully downloaded.
Definition acquire.h:763
unsigned long long TotalBytes
The total number of bytes that need to be fetched.
Definition acquire.h:743
unsigned long long CurrentCPS
The current rate of download as of the most recent call to pkgAcquireStatus::Pulse,...
Definition acquire.h:731
unsigned long long LastBytes
The number of bytes fetched as of the previous call to pkgAcquireStatus::Pulse, including local items...
Definition acquire.h:726
unsigned long TotalItems
The total number of items that need to be fetched.
Definition acquire.h:760
Represents the process by which a pkgAcquire object should retrieve a file or a collection of files.
Definition acquire-item.h:59
bool Shutdown(bool Final)
Shut down the worker process associated with this queue.
ItemIterator ItemsEnd()
Get the end iterator of the list of items.
Definition acquire.h:310
bool Pipeline
If true, this method supports pipelined downloading.
Definition acquire.h:667
bool NeedsCleanup
If true, the subprocess has to carry out some cleanup actions before shutting down.
Definition acquire.h:686
bool const Debug
If true, debugging information will be dumped to std::clog.
Definition acquire.h:174
MethodConfig()
Set up the default method parameters.
bool Enqueue(ItemDesc &Item)
Insert the given fetch request into this queue.
QItem * Items
The head of the list of items contained in this queue.
Definition acquire.h:485
bool Cycle()
Send idle items to the worker process.
Worker * WorkersBegin()
Get the first Worker object.
Definition acquire.h:296
bool ItemDone(QItem *Itm)
Remove the given item from this queue and set its state to pkgAcquire::Item::StatDone.
std::string Description
description of this item.
Definition acquire.h:395
bool SingleInstance
If true, only one download queue should be created for this method.
Definition acquire.h:664
QItem * FindItem(std::string URI, pkgAcquire::Worker *Owner) APT_PURE
Locate an item in this queue.
bool ItemStart(QItem *Itm, unsigned long long Size)
pkgAcquire * Owner
the download scheduler with which this queue is associated.
Definition acquire.h:499
std::vector< Item * > Items
A list of items to download.
Definition acquire.h:126
bool Removable
If true, this fetch method acquires files from removable media.
Definition acquire.h:689
bool Dequeue(Item *Owner)
Remove all fetch requests for the given item from this queue.
bool LocalOnly
If true, this fetch method does not require network access; all files are to be acquired from the loc...
Definition acquire.h:678
std::string Version
The implementation version of this acquire method.
Definition acquire.h:659
signed long PipeDepth
The number of entries in this queue that are currently being downloaded.
Definition acquire.h:504
std::string ShortDesc
shorter description of this item.
Definition acquire.h:397
Queue(std::string const &Name, pkgAcquire *const Owner)
Create a new Queue.
Item * Owner
underlying item which is to be downloaded.
Definition acquire.h:399
Queue * Queues
The head of the list of active queues.
Definition acquire.h:133
std::string URI
URI from which to download this item.
Definition acquire.h:393
MethodConfig * Configs
The head of the list of acquire method configurations.
Definition acquire.h:152
bool Startup()
Start the worker process associated with this queue.
unsigned long ToFetch
The number of files which are to be fetched.
Definition acquire.h:158
void Bump()
Check for items that could be enqueued.
Worker(Queue *OwnerQ, MethodConfig *Config, pkgAcquireStatus *Log)
Create a new Worker to download files.
RunResult
Provides information on how a download terminated.
Definition acquire.h:262
@ Failed
Some files failed to download.
Definition acquire.h:267
@ Continue
All files were fetched successfully.
Definition acquire.h:264
UriIterator(pkgAcquire::Queue *Q)
Create a new UriIterator.
std::string Name
The name of this queue.
Definition acquire.h:479
MethodConfig * Next
The next link on the acquire method list.
Definition acquire.h:653
Worker * Workers
The head of the list of active workers.
Definition acquire.h:140
bool Running
If true, a download is currently in progress.
Definition acquire.h:176
pkgAcquire::Worker * Workers
The head of the list of workers associated with this queue.
Definition acquire.h:496
bool SendConfig
If true, the worker process should send the entire APT configuration tree to the fetch subprocess whe...
Definition acquire.h:673
QueueStrategy
Represents the queuing strategy for remote URIs.
Definition acquire.h:163
@ QueueHost
Generate one queue for each protocol/host combination; downloads from multiple hosts can proceed in p...
Definition acquire.h:167
ItemIterator ItemsBegin()
Get the head of the list of items.
Definition acquire.h:306
unsigned long MaxPipeDepth
The maximum number of entries that this queue will attempt to download at once.
Definition acquire.h:509
std::string From
Definition acquire.h:814
std::string Type
Definition acquire.h:813
std::string Message
Definition acquire.h:816
bool DefaultAction
Definition acquire.h:817
std::string To
Definition acquire.h:815
A single item placed in this queue.
Definition acquire.h:422
int APT_HIDDEN GetPriority() const
unsigned long long GetMaximumSize() const
HashStringList GetExpectedHashes() const
void SyncDestinationFiles() const
get partial files in order
time_point APT_HIDDEN GetFetchAfter() const
QItem * Next
The next item in the queue.
Definition acquire.h:424
pkgAcquire::Worker * Worker
The worker associated with this item, if any.
Definition acquire.h:426
std::vector< Item * > Owners
The underlying items interested in the download.
Definition acquire.h:429
std::string Custom600Headers() const