libapt-pkg-dev  v0.9.7.5ubuntu5.4
Debian+Ubuntu APT Package Management
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pkgAcqFile Class Reference

Retrieve an arbitrary file to the current directory. More...

#include <acquire-item.h>

Inheritance diagram for pkgAcqFile:
Collaboration diagram for pkgAcqFile:

Public Types

enum  ItemState {
  StatIdle,
  StatFetching,
  StatDone,
  StatError,
  StatAuthError,
  StatTransientNetworkError
}
 The current status of this item. More...
 

Public Member Functions

 pkgAcqFile (pkgAcquire *Owner, std::string URI, std::string Hash, unsigned long long Size, std::string Desc, std::string ShortDesc, const std::string &DestDir="", const std::string &DestFilename="", bool IsIndexFile=false)
 Create a new pkgAcqFile object. More...
 
void AddWeakPointer (WeakPointable **weakptr)
 Add a new weak pointer. More...
 
virtual std::string Custom600Headers ()
 Custom headers to be sent to the fetch process. More...
 
virtual std::string DescURI ()
 A "descriptive" URI-like string. More...
 
virtual void Done (std::string Message, unsigned long long Size, std::string CalcHash, pkgAcquire::MethodConfig *Cnf)
 Invoked by the acquire worker when the object was fetched successfully. More...
 
virtual void Failed (std::string Message, pkgAcquire::MethodConfig *Cnf)
 Invoked by the acquire worker when the object couldn't be fetched. More...
 
virtual void Finished ()
 Invoked by the worker when the download is completely done. More...
 
pkgAcquireGetOwner ()
 
virtual std::string HashSum ()
 HashSum. More...
 
virtual bool IsTrusted ()
 
void RemoveWeakPointer (WeakPointable **weakptr)
 Remove the weak pointer from the list of weak pointers. More...
 
void ReportMirrorFailure (std::string FailCode)
 Report mirror problem. More...
 
virtual std::string ShortDesc ()
 Short item description. More...
 
virtual void Start (std::string Message, unsigned long long Size)
 Invoked when the worker starts to fetch this object. More...
 

Public Attributes

bool Complete
 If true, the entire object has been successfully fetched. More...
 
std::string DestFile
 The name of the file into which the retrieved object will be written. More...
 
std::string ErrorText
 Contains a textual description of the error encountered if Status is StatError or StatAuthError. More...
 
unsigned long long FileSize
 The size of the object to fetch. More...
 
unsigned long ID
 A client-supplied unique identifier. More...
 
bool Local
 If true, the URI of this object is "local". More...
 
const char * Mode
 If not NULL, contains the name of a subprocess that is operating on this object (for instance, "gzip" or "gpgv"). More...
 
unsigned long long PartialSize
 How much of the object was already fetched. More...
 
unsigned int QueueCounter
 The number of fetch queues into which this item has been inserted. More...
 
enum pkgAcquire::Item::ItemState Status
 
std::string UsedMirror
 

Protected Member Functions

void Dequeue ()
 Remove this item from its owner's queue. More...
 
void QueueURI (ItemDesc &Item)
 Insert this item into its owner's queue. More...
 
void Rename (std::string From, std::string To)
 Rename a file without modifying its timestamp. More...
 

Protected Attributes

pkgAcquireOwner
 The acquire object with which this item is associated. More...
 

Private Attributes

pkgAcquire::ItemDesc Desc
 The currently active download process. More...
 
HashString ExpectedHash
 The hashsum of the file to download, if it is known. More...
 
bool IsIndexFile
 Should this file be considered a index file. More...
 
unsigned int Retries
 How many times to retry the download, set from Acquire::Retries. More...
 

Detailed Description

Retrieve an arbitrary file to the current directory.

    {{{

The file is retrieved even if it is accessed via a URL type that normally is a NOP, such as "file". If the download fails, the partial file is renamed to get a ".FAILED" extension.

Member Enumeration Documentation

The current status of this item.

Enumerator
StatIdle 

The item is waiting to be downloaded.

StatFetching 

The item is currently being downloaded.

StatDone 

The item has been successfully downloaded.

StatError 

An error was encountered while downloading this item.

StatAuthError 

The item was downloaded but its authenticity could not be verified.

StatTransientNetworkError 

The item was could not be downloaded because of a transient network error (e.g.

network down)

Constructor & Destructor Documentation

pkgAcqFile::pkgAcqFile ( pkgAcquire Owner,
std::string  URI,
std::string  Hash,
unsigned long long  Size,
std::string  Desc,
std::string  ShortDesc,
const std::string &  DestDir = "",
const std::string &  DestFilename = "",
bool  IsIndexFile = false 
)

Create a new pkgAcqFile object.

Parameters
OwnerThe pkgAcquire object with which this object is associated.
URIThe URI to download.
HashThe hashsum of the file to download, if it is known; otherwise "".
SizeThe size of the file to download, if it is known; otherwise 0.
DescA description of the file being downloaded.
ShortDescA brief description of the file being downloaded.
DestDirThe directory the file should be downloaded into.
DestFilenameThe filename+path the file is downloaded to.
IsIndexFileThe file is considered a IndexFile and cache-control headers like "cache-control: max-age=0" are send

If DestFilename is empty, download to DestDir/<basename> if DestDir is non-empty, $CWD/<basename> otherwise. If DestFilename is NOT empty, DestDir is ignored and DestFilename is the absolute name to which the file should be downloaded.

Member Function Documentation

void WeakPointable::AddWeakPointer ( WeakPointable **  weakptr)
inlineinherited

Add a new weak pointer.

References WeakPointable::pointers.

virtual std::string pkgAcqFile::Custom600Headers ( )
virtual

Custom headers to be sent to the fetch process.

Returns
a string containing RFC822-style headers that are to be inserted into the 600 URI Acquire message sent to the fetch subprocess. The headers are inserted after a newline-less line, so they should (if nonempty) have a leading newline and no trailing newline.

Reimplemented from pkgAcquire::Item.

void pkgAcquire::Item::Dequeue ( )
inlineprotectedinherited

Remove this item from its owner's queue.

References pkgAcquire::Dequeue(), and pkgAcquire::Item::Owner.

Here is the call graph for this function:

virtual std::string pkgAcqFile::DescURI ( )
inlinevirtual

A "descriptive" URI-like string.

Returns
a URI that should be used to describe what is being fetched.

Implements pkgAcquire::Item.

References Desc, and pkgAcquire::ItemDesc::URI.

virtual void pkgAcqFile::Done ( std::string  Message,
unsigned long long  Size,
std::string  Hash,
pkgAcquire::MethodConfig Cnf 
)
virtual

Invoked by the acquire worker when the object was fetched successfully.

Note that the object might not have been written to DestFile; check for the presence of an Alt-Filename entry in Message to find the file to which it was really written.

Done is often used to switch from one stage of the processing to the next (e.g. fetching, unpacking, copying). It is one branch of the continuation of the fetch process.

Parameters
MessageData from the acquire method. Use LookupTag() to parse it.
SizeThe size of the object that was fetched.
HashThe HashSum of the object that was fetched.
CnfThe method via which the object was fetched.
See Also
pkgAcqMethod

Reimplemented from pkgAcquire::Item.

virtual void pkgAcqFile::Failed ( std::string  Message,
pkgAcquire::MethodConfig Cnf 
)
virtual

Invoked by the acquire worker when the object couldn't be fetched.

This is a branch of the continuation of the fetch process.

Parameters
MessageAn RFC822-formatted message from the acquire method describing what went wrong. Use LookupTag() to parse it.
CnfThe method via which the worker tried to fetch this object.
See Also
pkgAcqMethod

Reimplemented from pkgAcquire::Item.

virtual void pkgAcquire::Item::Finished ( )
inlinevirtualinherited

Invoked by the worker when the download is completely done.

Reimplemented in pkgAcqArchive.

pkgAcquire* pkgAcquire::Item::GetOwner ( )
inlineinherited
Returns
the acquire process with which this item is associated.

References pkgAcquire::Item::Owner.

virtual std::string pkgAcqFile::HashSum ( )
inlinevirtual

HashSum.

Returns
the HashSum of this object, if applicable; otherwise, an empty string.

Reimplemented from pkgAcquire::Item.

References ExpectedHash, and HashString::toStr().

Here is the call graph for this function:

virtual bool pkgAcquire::Item::IsTrusted ( )
inlinevirtualinherited
Returns
true if this object is being fetched from a trusted source.

Reimplemented in pkgAcqArchive.

void pkgAcquire::Item::QueueURI ( ItemDesc Item)
inlineprotectedinherited

Insert this item into its owner's queue.

Parameters
ItemDescMetadata about this item (its URI and description).

References pkgAcquire::Enqueue(), and pkgAcquire::Item::Owner.

Here is the call graph for this function:

void WeakPointable::RemoveWeakPointer ( WeakPointable **  weakptr)
inlineinherited

Remove the weak pointer from the list of weak pointers.

References WeakPointable::pointers.

void pkgAcquire::Item::Rename ( std::string  From,
std::string  To 
)
protectedinherited

Rename a file without modifying its timestamp.

Many item methods call this as their final action.

Parameters
FromThe file to be renamed.
ToThe new name of #From. If #To exists it will be overwritten.
void pkgAcquire::Item::ReportMirrorFailure ( std::string  FailCode)
inherited

Report mirror problem.

This allows reporting mirror failures back to a centralized server. The apt-report-mirror-failure script is called for this

Parameters
FailCodeA short failure string that is send
virtual std::string pkgAcquire::Item::ShortDesc ( )
inlinevirtualinherited

Short item description.

Returns
a brief description of the object being fetched.

Reimplemented in pkgAcqArchive.

References pkgAcquire::Item::DescURI().

Here is the call graph for this function:

virtual void pkgAcquire::Item::Start ( std::string  Message,
unsigned long long  Size 
)
virtualinherited

Invoked when the worker starts to fetch this object.

Parameters
MessageRFC822-formatted data from the worker process. Use LookupTag() to parse it.
SizeThe size of the object being fetched.
See Also
pkgAcqMethod

Member Data Documentation

bool pkgAcquire::Item::Complete
inherited

If true, the entire object has been successfully fetched.

Subclasses should set this to true when appropriate.

pkgAcquire::ItemDesc pkgAcqFile::Desc
private

The currently active download process.

Referenced by DescURI().

std::string pkgAcquire::Item::DestFile
inherited

The name of the file into which the retrieved object will be written.

std::string pkgAcquire::Item::ErrorText
inherited

Contains a textual description of the error encountered if Status is StatError or StatAuthError.

HashString pkgAcqFile::ExpectedHash
private

The hashsum of the file to download, if it is known.

Referenced by HashSum().

unsigned long long pkgAcquire::Item::FileSize
inherited

The size of the object to fetch.

unsigned long pkgAcquire::Item::ID
inherited

A client-supplied unique identifier.

This field is initalized to 0; it is meant to be filled in by clients that wish to use it to uniquely identify items.

Todo:
it's unused in apt itself
bool pkgAcqFile::IsIndexFile
private

Should this file be considered a index file.

bool pkgAcquire::Item::Local
inherited

If true, the URI of this object is "local".

The only effect of this field is to exclude the object from the download progress indicator's overall statistics.

const char* pkgAcquire::Item::Mode
inherited

If not NULL, contains the name of a subprocess that is operating on this object (for instance, "gzip" or "gpgv").

pkgAcquire* pkgAcquire::Item::Owner
protectedinherited

The acquire object with which this item is associated.

Referenced by pkgAcquire::Item::Dequeue(), pkgAcquire::Item::GetOwner(), and pkgAcquire::Item::QueueURI().

unsigned long long pkgAcquire::Item::PartialSize
inherited

How much of the object was already fetched.

unsigned int pkgAcquire::Item::QueueCounter
inherited

The number of fetch queues into which this item has been inserted.

There is one queue for each source from which an item could be downloaded.

See Also
pkgAcquire
unsigned int pkgAcqFile::Retries
private

How many times to retry the download, set from Acquire::Retries.

enum pkgAcquire::Item::ItemState pkgAcquire::Item::Status
inherited
std::string pkgAcquire::Item::UsedMirror
inherited

The documentation for this class was generated from the following file: