summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc89
-rw-r--r--apt-pkg/acquire-item.h63
2 files changed, 88 insertions, 64 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index ce19e5486..99013d649 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -354,11 +354,10 @@ bool pkgAcqSubIndex::ParseIndex(string const &IndexFile) /*{{{*/
* the original packages file
*/
pkgAcqDiffIndex::pkgAcqDiffIndex(pkgAcquire *Owner,
- IndexTarget const * const Target,
- HashStringList const &ExpectedHashes,
- indexRecords *MetaIndexParser)
- : Item(Owner, ExpectedHashes), Target(Target),
- MetaIndexParser(MetaIndexParser)
+ IndexTarget const * const Target,
+ HashStringList const &ExpectedHashes,
+ indexRecords *MetaIndexParser)
+ : pkgAcqBaseIndex(Owner, Target, ExpectedHashes, MetaIndexParser)
{
Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
@@ -456,8 +455,8 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile) /*{{{*/
std::clog << "Package file is up-to-date" << std::endl;
// list cleanup needs to know that this file as well as the already
// present index is ours, so we create an empty diff to save it for us
- new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc,
- ExpectedHashes, ServerSha1, available_patches);
+ new pkgAcqIndexDiffs(Owner, Target, ExpectedHashes, MetaIndexParser,
+ ServerSha1, available_patches);
return true;
}
else
@@ -542,14 +541,19 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile) /*{{{*/
}
if (pdiff_merge == false)
- new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc,
- ExpectedHashes, ServerSha1, available_patches);
- else
+ {
+ new pkgAcqIndexDiffs(Owner, Target, ExpectedHashes, MetaIndexParser,
+ ServerSha1, available_patches);
+ }
+ else
{
std::vector<pkgAcqIndexMergeDiffs*> *diffs = new std::vector<pkgAcqIndexMergeDiffs*>(available_patches.size());
for(size_t i = 0; i < available_patches.size(); ++i)
- (*diffs)[i] = new pkgAcqIndexMergeDiffs(Owner, RealURI, Description, Desc.ShortDesc, ExpectedHashes,
- available_patches[i], diffs);
+ (*diffs)[i] = new pkgAcqIndexMergeDiffs(Owner, Target,
+ ExpectedHashes,
+ MetaIndexParser,
+ available_patches[i],
+ diffs);
}
Complete = false;
@@ -616,22 +620,24 @@ void pkgAcqDiffIndex::Done(string Message,unsigned long long Size,HashStringList
* for each diff and the index
*/
pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire *Owner,
- string URI,string URIDesc,string ShortDesc,
- HashStringList const &ExpectedHashes,
+ struct IndexTarget const * const Target,
+ HashStringList const &ExpectedHashes,
+ indexRecords *MetaIndexParser,
string ServerSha1,
vector<DiffInfo> diffs)
- : Item(Owner, ExpectedHashes), RealURI(URI),
+ : pkgAcqBaseIndex(Owner, Target, ExpectedHashes, MetaIndexParser),
available_patches(diffs), ServerSha1(ServerSha1)
{
DestFile = _config->FindDir("Dir::State::lists") + "partial/";
- DestFile += URItoFileName(URI);
+ DestFile += URItoFileName(Target->URI);
Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
- Description = URIDesc;
+ RealURI = Target->URI;
Desc.Owner = this;
- Desc.ShortDesc = ShortDesc;
+ Description = Target->Description;
+ Desc.ShortDesc = Target->ShortDesc;
if(available_patches.empty() == true)
{
@@ -651,7 +657,7 @@ void pkgAcqIndexDiffs::Failed(string Message,pkgAcquire::MethodConfig * /*Cnf*/)
if(Debug)
std::clog << "pkgAcqIndexDiffs failed: " << Desc.URI << " with " << Message << std::endl
<< "Falling back to normal index file acquire" << std::endl;
- new pkgAcqIndex(Owner, RealURI, Description,Desc.ShortDesc, HashSums());
+ new pkgAcqIndex(Owner, Target, ExpectedHashes, MetaIndexParser);
Finish();
}
/*}}}*/
@@ -791,8 +797,9 @@ void pkgAcqIndexDiffs::Done(string Message,unsigned long long Size, HashStringLi
// see if there is more to download
if(available_patches.empty() == false) {
- new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc,
- HashSums(), ServerSha1, available_patches);
+ new pkgAcqIndexDiffs(Owner, Target,
+ ExpectedHashes, MetaIndexParser,
+ ServerSha1, available_patches);
return Finish();
} else
return Finish(true);
@@ -801,22 +808,24 @@ void pkgAcqIndexDiffs::Done(string Message,unsigned long long Size, HashStringLi
/*}}}*/
// AcqIndexMergeDiffs::AcqIndexMergeDiffs - Constructor /*{{{*/
pkgAcqIndexMergeDiffs::pkgAcqIndexMergeDiffs(pkgAcquire *Owner,
- string const &URI, string const &URIDesc,
- string const &ShortDesc, HashStringList const &ExpectedHashes,
- DiffInfo const &patch,
- std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches)
- : Item(Owner, ExpectedHashes), RealURI(URI),
- patch(patch),allPatches(allPatches), State(StateFetchDiff)
+ struct IndexTarget const * const Target,
+ HashStringList const &ExpectedHashes,
+ indexRecords *MetaIndexParser,
+ DiffInfo const &patch,
+ std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches)
+ : pkgAcqBaseIndex(Owner, Target, ExpectedHashes, MetaIndexParser),
+ patch(patch), allPatches(allPatches), State(StateFetchDiff)
{
DestFile = _config->FindDir("Dir::State::lists") + "partial/";
- DestFile += URItoFileName(URI);
+ DestFile += URItoFileName(Target->URI);
Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
- Description = URIDesc;
+ RealURI = Target->URI;
Desc.Owner = this;
- Desc.ShortDesc = ShortDesc;
+ Description = Target->Description;
+ Desc.ShortDesc = Target->ShortDesc;
Desc.URI = RealURI + ".diff/" + patch.file + ".gz";
Desc.Description = Description + " " + patch.file + string(".pdiff");
@@ -847,8 +856,7 @@ void pkgAcqIndexMergeDiffs::Failed(string Message,pkgAcquire::MethodConfig * /*C
// first failure means we should fallback
State = StateErrorDiff;
std::clog << "Falling back to normal index file acquire" << std::endl;
- new pkgAcqIndex(Owner, RealURI, Description,Desc.ShortDesc,
- ExpectedHashes);
+ new pkgAcqIndex(Owner, Target, ExpectedHashes, MetaIndexParser);
}
/*}}}*/
void pkgAcqIndexMergeDiffs::Done(string Message,unsigned long long Size,HashStringList const &Hashes, /*{{{*/
@@ -930,9 +938,8 @@ void pkgAcqIndexMergeDiffs::Done(string Message,unsigned long long Size,HashStri
instantiated to fetch the revision file */
pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,
string URI,string URIDesc,string ShortDesc,
- HashStringList const &ExpectedHashes, string comprExt)
- : Item(Owner, ExpectedHashes), RealURI(URI), Target(0),
- MetaIndexParser(0)
+ HashStringList const &ExpectedHash, string comprExt)
+ : pkgAcqBaseIndex(Owner, NULL, ExpectedHash, NULL), RealURI(URI)
{
if(comprExt.empty() == true)
{
@@ -949,9 +956,11 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,
Init(URI, URIDesc, ShortDesc);
}
-pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner, IndexTarget const * const Target,
- HashStringList const &ExpectedHashes, indexRecords *MetaIndexParser)
- : Item(Owner, ExpectedHashes), RealURI(Target->URI)
+pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner, IndexTarget const *Target,
+ HashStringList const &ExpectedHash,
+ indexRecords *MetaIndexParser)
+ : pkgAcqBaseIndex(Owner, Target, ExpectedHash, MetaIndexParser),
+ RealURI(Target->URI)
{
// autoselect the compression method
std::vector<std::string> types = APT::Configuration::getCompressionTypes();
@@ -977,10 +986,6 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner, IndexTarget const * const Target,
else
Verify = true;
- // we need this in Init()
- this->Target = Target;
- this->MetaIndexParser = MetaIndexParser;
-
Init(Target->URI, Target->Description, Target->ShortDesc);
}
/*}}}*/
diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h
index d054b96af..3d863874c 100644
--- a/apt-pkg/acquire-item.h
+++ b/apt-pkg/acquire-item.h
@@ -366,6 +366,27 @@ class pkgAcqSubIndex : public pkgAcquire::Item
std::string const &ShortDesc, HashStringList const &ExpectedHashes);
};
/*}}}*/
+
+/** \brief Common base class for all classes that deal with fetching {{{
+ indexes
+ */
+class pkgAcqBaseIndex : public pkgAcquire::Item
+{
+ protected:
+ /** \brief Pointer to the IndexTarget data
+ */
+ const struct IndexTarget * Target;
+ indexRecords *MetaIndexParser;
+
+ pkgAcqBaseIndex(pkgAcquire *Owner,
+ struct IndexTarget const * const Target,
+ HashStringList const &ExpectedHashes,
+ indexRecords *MetaIndexParser)
+ : Item(Owner, ExpectedHashes), Target(Target),
+ MetaIndexParser(MetaIndexParser) {};
+
+};
+ /*}}}*/
/** \brief An item that is responsible for fetching an index file of {{{
* package list diffs and starting the package list's download.
*
@@ -375,7 +396,7 @@ class pkgAcqSubIndex : public pkgAcquire::Item
*
* \sa pkgAcqIndexDiffs, pkgAcqIndex
*/
-class pkgAcqDiffIndex : public pkgAcquire::Item
+class pkgAcqDiffIndex : public pkgAcqBaseIndex
{
protected:
/** \brief If \b true, debugging information will be written to std::clog. */
@@ -396,11 +417,6 @@ class pkgAcqDiffIndex : public pkgAcquire::Item
*/
std::string Description;
- /** \brief Pointer to the IndexTarget data
- */
- const struct IndexTarget * Target;
- indexRecords *MetaIndexParser;
-
public:
// Specialized action members
virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
@@ -451,7 +467,7 @@ class pkgAcqDiffIndex : public pkgAcquire::Item
*
* \sa pkgAcqDiffIndex, pkgAcqIndex
*/
-class pkgAcqIndexMergeDiffs : public pkgAcquire::Item
+class pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex
{
protected:
@@ -522,9 +538,12 @@ class pkgAcqIndexMergeDiffs : public pkgAcquire::Item
* \param allPatches contains all related items so that each item can
* check if it was the last one to complete the download step
*/
- pkgAcqIndexMergeDiffs(pkgAcquire *Owner,std::string const &URI,std::string const &URIDesc,
- std::string const &ShortDesc, HashStringList const &ExpectedHashes,
- DiffInfo const &patch, std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches);
+ pkgAcqIndexMergeDiffs(pkgAcquire *Owner,
+ struct IndexTarget const * const Target,
+ HashStringList const &ExpectedHash,
+ indexRecords *MetaIndexParser,
+ DiffInfo const &patch,
+ std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches);
};
/*}}}*/
/** \brief An item that is responsible for fetching server-merge patches {{{
@@ -538,7 +557,7 @@ class pkgAcqIndexMergeDiffs : public pkgAcquire::Item
*
* \sa pkgAcqDiffIndex, pkgAcqIndex
*/
-class pkgAcqIndexDiffs : public pkgAcquire::Item
+class pkgAcqIndexDiffs : public pkgAcqBaseIndex
{
private:
@@ -647,8 +666,10 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item
* should be ordered so that each diff appears before any diff
* that depends on it.
*/
- pkgAcqIndexDiffs(pkgAcquire *Owner,std::string URI,std::string URIDesc,
- std::string ShortDesc, HashStringList const &ExpectedHashes,
+ pkgAcqIndexDiffs(pkgAcquire *Owner,
+ struct IndexTarget const * const Target,
+ HashStringList const &ExpectedHash,
+ indexRecords *MetaIndexParser,
std::string ServerSha1,
std::vector<DiffInfo> diffs=std::vector<DiffInfo>());
};
@@ -660,7 +681,7 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item
*
* \todo Why does pkgAcqIndex have protected members?
*/
-class pkgAcqIndex : public pkgAcquire::Item
+class pkgAcqIndex : public pkgAcqBaseIndex
{
protected:
@@ -692,11 +713,6 @@ class pkgAcqIndex : public pkgAcquire::Item
*/
std::string CompressionExtension;
- /** \brief Pointer to the IndexTarget data
- */
- const struct IndexTarget * Target;
- indexRecords *MetaIndexParser;
-
public:
// Specialized action members
@@ -728,9 +744,12 @@ class pkgAcqIndex : public pkgAcquire::Item
pkgAcqIndex(pkgAcquire *Owner,std::string URI,std::string URIDesc,
std::string ShortDesc, HashStringList const &ExpectedHashes,
std::string compressExt="");
- pkgAcqIndex(pkgAcquire *Owner, IndexTarget const * const Target,
- HashStringList const &ExpectedHashes, indexRecords *MetaIndexParser);
- void Init(std::string const &URI, std::string const &URIDesc, std::string const &ShortDesc);
+ pkgAcqIndex(pkgAcquire *Owner,
+ struct IndexTarget const * const Target,
+ HashStringList const &ExpectedHash,
+ indexRecords *MetaIndexParser);
+ void Init(std::string const &URI, std::string const &URIDesc,
+ std::string const &ShortDesc);
};
/*}}}*/
/** \brief An acquire item that is responsible for fetching a {{{