Author: jgg
Date: 1999-02-01 02:22:11 GMT
Arranged to rename downloaded files to include all important info
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: acquire-item.cc,v 1.21 1999/01/31 22:25:34 jgg Exp $
+// $Id: acquire-item.cc,v 1.22 1999/02/01 02:22:11 jgg Exp $
/* ######################################################################
Acquire Item - Item to acquire
/* ######################################################################
Acquire Item - Item to acquire
{
/* This indicates that the file is not available right now but might
be sometime later. If we do a retry cycle then this should be
{
/* This indicates that the file is not available right now but might
be sometime later. If we do a retry cycle then this should be
if (Cnf->LocalOnly == true &&
StringToBool(LookupTag(Message,"Transient-Failure"),false) == true)
{
if (Cnf->LocalOnly == true &&
StringToBool(LookupTag(Message,"Transient-Failure"),false) == true)
{
/*}}}*/
// Acquire::Item::Start - Item has begun to download /*{{{*/
// ---------------------------------------------------------------------
/*}}}*/
// Acquire::Item::Start - Item has begun to download /*{{{*/
// ---------------------------------------------------------------------
+/* Stash status and the file size. Note that setting Complete means
+ sub-phases of the acquire process such as decompresion are operating */
void pkgAcquire::Item::Start(string Message,unsigned long Size)
{
Status = StatFetching;
void pkgAcquire::Item::Start(string Message,unsigned long Size)
{
Status = StatFetching;
// AcqArchive::AcqArchive - Constructor /*{{{*/
// ---------------------------------------------------------------------
// AcqArchive::AcqArchive - Constructor /*{{{*/
// ---------------------------------------------------------------------
+/* This just sets up the initial fetch environment and queues the first
+ possibilitiy */
pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
pkgRecords *Recs,pkgCache::VerIterator const &Version,
string &StoreFilename) :
pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
pkgRecords *Recs,pkgCache::VerIterator const &Version,
string &StoreFilename) :
{
Retries = _config->FindI("Acquire::Retries",0);
{
Retries = _config->FindI("Acquire::Retries",0);
+ // Generate the final file name as: package_version_arch.deb
+ StoreFilename = QuoteString(Version.ParentPkg().Name(),"_:") + '_' +
+ QuoteString(Version.VerStr(),"_:") + '_' +
+ QuoteString(Version.Arch(),"_:") + ".deb";
+
// Select a source
if (QueueNext() == false && _error->PendingError() == false)
_error->Error("I wasn't able to locate file for the %s package. "
// Select a source
if (QueueNext() == false && _error->PendingError() == false)
_error->Error("I wasn't able to locate file for the %s package. "
/*}}}*/
// AcqArchive::QueueNext - Queue the next file source /*{{{*/
// ---------------------------------------------------------------------
/*}}}*/
// AcqArchive::QueueNext - Queue the next file source /*{{{*/
// ---------------------------------------------------------------------
-/* This queues the next available file version for download. */
+/* This queues the next available file version for download. It checks if
+ the archive is already available in the cache and stashs the MD5 for
+ checking later. */
bool pkgAcqArchive::QueueNext()
{
for (; Vf.end() == false; Vf++)
bool pkgAcqArchive::QueueNext()
{
for (; Vf.end() == false; Vf++)
"field for package %s."
,Version.ParentPkg().Name());
"field for package %s."
,Version.ParentPkg().Name());
- // See if we already have the file.
+ // See if we already have the file. (Legacy filenames)
FileSize = Version->Size;
string FinalFile = _config->FindDir("Dir::Cache::Archives") + flNotDir(PkgFile);
struct stat Buf;
FileSize = Version->Size;
string FinalFile = _config->FindDir("Dir::Cache::Archives") + flNotDir(PkgFile);
struct stat Buf;
happen.. */
unlink(FinalFile.c_str());
}
happen.. */
unlink(FinalFile.c_str());
}
-
- DestFile = _config->FindDir("Dir::Cache::Archives") + "partial/" + flNotDir(PkgFile);
+
+ // Check it again using the new style output filenames
+ FinalFile = _config->FindDir("Dir::Cache::Archives") + flNotDir(StoreFilename);
+ if (stat(FinalFile.c_str(),&Buf) == 0)
+ {
+ // Make sure the size matches
+ if ((unsigned)Buf.st_size == Version->Size)
+ {
+ Complete = true;
+ Local = true;
+ Status = StatDone;
+ StoreFilename = DestFile = FinalFile;
+ return true;
+ }
+
+ /* Hmm, we have a file and its size does not match, this shouldnt
+ happen.. */
+ unlink(FinalFile.c_str());
+ }
+
+ DestFile = _config->FindDir("Dir::Cache::Archives") + "partial/" + flNotDir(StoreFilename);
// Create the item
Desc.URI = Location->ArchiveURI(PkgFile);
// Create the item
Desc.URI = Location->ArchiveURI(PkgFile);
// Done, move it into position
string FinalFile = _config->FindDir("Dir::Cache::Archives");
// Done, move it into position
string FinalFile = _config->FindDir("Dir::Cache::Archives");
- FinalFile += flNotDir(DestFile);
+ FinalFile += flNotDir(StoreFilename);
Rename(DestFile,FinalFile);
StoreFilename = DestFile = FinalFile;
Rename(DestFile,FinalFile);
StoreFilename = DestFile = FinalFile;
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: acquire-item.h,v 1.15 1999/01/31 22:25:34 jgg Exp $
+// $Id: acquire-item.h,v 1.16 1999/02/01 02:22:11 jgg Exp $
/* ######################################################################
Acquire Item - Item to acquire
When an item is instantiated it will add it self to the local list in
the Owner Acquire class. Derived classes will then call QueueURI to
/* ######################################################################
Acquire Item - Item to acquire
When an item is instantiated it will add it self to the local list in
the Owner Acquire class. Derived classes will then call QueueURI to
- register all the URI's they wish to fetch for at the initial moment.
+ register all the URI's they wish to fetch at the initial moment.
Two item classes are provided to provide functionality for downloading
of Index files and downloading of Packages.
A Archive class is provided for downloading .deb files. It does Md5
Two item classes are provided to provide functionality for downloading
of Index files and downloading of Packages.
A Archive class is provided for downloading .deb files. It does Md5
- checking and source location.
+ checking and source location as well as a retry algorithm.
##################################################################### */
/*}}}*/
##################################################################### */
/*}}}*/
+ // Some private helper methods for registering URIs
pkgAcquire *Owner;
inline void QueueURI(ItemDesc &Item)
{Owner->Enqueue(Item);};
inline void Dequeue() {Owner->Dequeue(this);};
pkgAcquire *Owner;
inline void QueueURI(ItemDesc &Item)
{Owner->Enqueue(Item);};
inline void Dequeue() {Owner->Dequeue(this);};
+ // Safe rename function with timestamp preservation
void Rename(string From,string To);
public:
void Rename(string From,string To);
public:
// File to write the fetch into
string DestFile;
// File to write the fetch into
string DestFile;
+ // Action members invoked by the worker
virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
virtual void Done(string Message,unsigned long Size,string Md5Hash);
virtual void Start(string Message,unsigned long Size);
virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
virtual void Done(string Message,unsigned long Size,string Md5Hash);
virtual void Start(string Message,unsigned long Size);
+ virtual string Custom600Headers() {return string();};
+
+ // Inquire functions
virtual string MD5Sum() {return string();};
virtual string Describe() = 0;
virtual string MD5Sum() {return string();};
virtual string Describe() = 0;
-
- virtual string Custom600Headers() {return string();};
-
Item(pkgAcquire *Owner);
virtual ~Item();
};
Item(pkgAcquire *Owner);
virtual ~Item();
};
+ // Specialized action members
virtual void Done(string Message,unsigned long Size,string Md5Hash);
virtual string Custom600Headers();
virtual string Describe();
virtual void Done(string Message,unsigned long Size,string Md5Hash);
virtual string Custom600Headers();
virtual string Describe();
+ // Specialized action members
virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
virtual void Done(string Message,unsigned long Size,string Md5Hash);
virtual string Custom600Headers();
virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
virtual void Done(string Message,unsigned long Size,string Md5Hash);
virtual string Custom600Headers();
+ // State information for the retry mechanism
pkgCache::VerIterator Version;
pkgAcquire::ItemDesc Desc;
pkgSourceList *Sources;
pkgCache::VerIterator Version;
pkgAcquire::ItemDesc Desc;
pkgSourceList *Sources;
string &StoreFilename;
pkgCache::VerFileIterator Vf;
unsigned int Retries;
string &StoreFilename;
pkgCache::VerFileIterator Vf;
unsigned int Retries;
+
+ // Queue the next available file for download.
bool QueueNext();
public:
bool QueueNext();
public:
+ // Specialized action members
virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
- virtual string MD5Sum() {return MD5;};
virtual void Done(string Message,unsigned long Size,string Md5Hash);
virtual string Describe();
virtual void Done(string Message,unsigned long Size,string Md5Hash);
virtual string Describe();
+ virtual string MD5Sum() {return MD5;};
pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
pkgRecords *Recs,pkgCache::VerIterator const &Version,
pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
pkgRecords *Recs,pkgCache::VerIterator const &Version,
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: cacheiterators.h,v 1.11 1998/12/14 08:07:28 jgg Exp $
+// $Id: cacheiterators.h,v 1.12 1999/02/01 02:22:11 jgg Exp $
/* ######################################################################
Cache Iterators - Iterators for navigating the cache structure
/* ######################################################################
Cache Iterators - Iterators for navigating the cache structure
inline const char *VerStr() const {return Ver->VerStr == 0?0:Owner.StrP + Ver->VerStr;};
inline const char *Section() const {return Ver->Section == 0?0:Owner.StrP + Ver->Section;};
inline const char *VerStr() const {return Ver->VerStr == 0?0:Owner.StrP + Ver->VerStr;};
inline const char *Section() const {return Ver->Section == 0?0:Owner.StrP + Ver->Section;};
+ inline const char *Arch() const {return Ver->Arch == 0?0:Owner.StrP + Ver->Arch;};
inline PkgIterator ParentPkg() const {return PkgIterator(Owner,Owner.PkgP + Ver->ParentPkg);};
inline DepIterator DependsList() const;
inline PrvIterator ProvidesList() const;
inline PkgIterator ParentPkg() const {return PkgIterator(Owner,Owner.PkgP + Ver->ParentPkg);};
inline DepIterator DependsList() const;
inline PrvIterator ProvidesList() const;
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: deblistparser.cc,v 1.14 1999/01/27 02:48:53 jgg Exp $
+// $Id: deblistparser.cc,v 1.15 1999/02/01 02:22:11 jgg Exp $
/* ######################################################################
Package Cache Generator - Generator for the cache structure.
/* ######################################################################
Package Cache Generator - Generator for the cache structure.
{
// Parse the section
Ver->Section = UniqFindTagWrite("Section");
{
// Parse the section
Ver->Section = UniqFindTagWrite("Section");
+ Ver->Arch = UniqFindTagWrite("Architecture");
// Archive Size
Ver->Size = (unsigned)Section.FindI("Size");
// Archive Size
Ver->Size = (unsigned)Section.FindI("Size");
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: pkgcache.h,v 1.15 1998/12/14 08:07:29 jgg Exp $
+// $Id: pkgcache.h,v 1.16 1999/02/01 02:22:11 jgg Exp $
/* ######################################################################
Cache - Structure definitions for the cache file
/* ######################################################################
Cache - Structure definitions for the cache file
{
__apt_ptrloc VerStr; // Stringtable
__apt_ptrloc Section; // StringTable (StringItem)
{
__apt_ptrloc VerStr; // Stringtable
__apt_ptrloc Section; // StringTable (StringItem)
+ __apt_ptrloc Arch; // StringTable
+
// Lists
__apt_ptrloc FileList; // VerFile
__apt_ptrloc NextVer; // Version
// Lists
__apt_ptrloc FileList; // VerFile
__apt_ptrloc NextVer; // Version
<title>APT Cache File Format</title>
<author>Jason Gunthorpe <email>jgg@debian.org</email></author>
<title>APT Cache File Format</title>
<author>Jason Gunthorpe <email>jgg@debian.org</email></author>
-<version>$Id: cache.sgml,v 1.5 1998/12/14 08:23:10 jgg Exp $</version>
+<version>$Id: cache.sgml,v 1.6 1999/02/01 02:22:11 jgg Exp $</version>
<abstract>
This document describes the complete implementation and format of the APT
<abstract>
This document describes the complete implementation and format of the APT
{
unsigned long VerStr; // Stringtable
unsigned long Section; // StringTable (StringItem)
{
unsigned long VerStr; // Stringtable
unsigned long Section; // StringTable (StringItem)
+ unsigned long Arch; // StringTable
// Lists
unsigned long FileList; // VerFile
// Lists
unsigned long FileList; // VerFile
This string indicates which section it is part of. The string should be
contained in the StringItem list.
This string indicates which section it is part of. The string should be
contained in the StringItem list.
+<tag>Arch<item>
+Architecture the package was compiled for.
+
<tag>NextVer<item>
Next step in the linked list.
<tag>NextVer<item>
Next step in the linked list.