summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorMichael Vogt <mvo@ubuntu.com>2014-09-29 17:38:23 +0200
committerMichael Vogt <mvo@ubuntu.com>2014-09-29 17:38:23 +0200
commitfa3a96a1051d65e5aa8cd9e9e0bb854ccc67a4b6 (patch)
tree25e1271f2c5ac0a8f7a8facd9402a28133892d1a /apt-pkg
parent7a8e00715588564a5b9434eaad65f2c6d3e513bb (diff)
cleanup
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc49
-rw-r--r--apt-pkg/acquire-item.h36
2 files changed, 54 insertions, 31 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 3d6924847..5beb7e190 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -627,7 +627,9 @@ void pkgAcqIndexDiffs::Finish(bool allDone)
// this happens if we have a up-to-date indexfile
if(!FileExists(PartialFile))
PartialFile = DestFile;
-
+
+ TransactionManager->TransactionStageCopy(this, PartialFile, DestFile);
+
// this is for the "real" finish
Complete = true;
Status = StatDone;
@@ -892,8 +894,7 @@ void pkgAcqIndexMergeDiffs::Done(string Message,unsigned long long Size,HashStri
<< DestFile << " -> " << FinalFile << std::endl;
// queue for copy by the transaction manager
- PartialFile = DestFile;
- DestFile = FinalFile;
+ TransactionManager->TransactionStageCopy(this, DestFile, FinalFile);
// ensure the ed's are gone regardless of list-cleanup
for (std::vector<pkgAcqIndexMergeDiffs *>::const_iterator I = allPatches->begin();
@@ -1178,8 +1179,7 @@ void pkgAcqIndex::Done(string Message, unsigned long long Size,
unlink(CompressedFile.c_str());
// Done, queue for rename on transaction finished
- PartialFile = DestFile;
- DestFile = GetFinalFilename();
+ TransactionManager->TransactionStageCopy(this, DestFile, GetFinalFilename());
return;
}
@@ -1428,6 +1428,22 @@ void pkgAcqMetaBase::CommitTransaction()
}
}
+void pkgAcqMetaBase::TransactionStageCopy(Item *I,
+ const std::string &From,
+ const std::string &To)
+{
+ I->PartialFile = From;
+ I->DestFile = To;
+}
+
+void pkgAcqMetaBase::TransactionStageRemoval(Item *I,
+ const std::string &FinalFile)
+{
+ I->PartialFile = "";
+ I->DestFile = FinalFile;
+}
+
+
/*{{{*/
bool pkgAcqMetaBase::GenerateAuthWarning(const std::string &RealURI,
const std::string &Message)
@@ -1473,7 +1489,7 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner, /*{{{*/
pkgAcqMetaBase(Owner, IndexTargets, MetaIndexParser,
HashStringList(), TransactionManager),
RealURI(URI), MetaIndexFile(MetaIndexFile), URIDesc(URIDesc),
- ShortDesc(ShortDesc), AuthPass(false), IMSHit(false)
+ ShortDesc(ShortDesc)
{
DestFile = _config->FindDir("Dir::State::lists") + "partial/";
DestFile += URItoFileName(URI);
@@ -1547,7 +1563,7 @@ void pkgAcqMetaSig::Done(string Message,unsigned long long Size, HashStringList
string FinalFile = _config->FindDir("Dir::State::lists");
FinalFile += URItoFileName(RealURI);
- DestFile = PartialFile = FinalFile;
+ TransactionManager->TransactionStageCopy(this, FinalFile, FinalFile);
}
// queue for verify
@@ -1567,8 +1583,10 @@ void pkgAcqMetaSig::Done(string Message,unsigned long long Size, HashStringList
PartialFile = _config->FindDir("Dir::State::lists") + "partial/";
PartialFile += URItoFileName(RealURI);
- DestFile = _config->FindDir("Dir::State::lists");
- DestFile += URItoFileName(RealURI);
+ std::string FinalFile = _config->FindDir("Dir::State::lists");
+ FinalFile += URItoFileName(RealURI);
+
+ TransactionManager->TransactionStageCopy(this, PartialFile, FinalFile);
}
// we parse the MetaIndexFile here because at this point we can
@@ -1606,7 +1624,7 @@ void pkgAcqMetaSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf)/*{{{*/
// transaction
DestFile = _config->FindDir("Dir::State::lists") + "partial/";
DestFile += URItoFileName(RealURI);
- PartialFile = "";
+ TransactionManager->TransactionStageRemoval(this, DestFile);
// FIXME: duplicated code from pkgAcqMetaIndex
if (AuthPass == true)
@@ -1651,7 +1669,6 @@ pkgAcqMetaIndex::pkgAcqMetaIndex(pkgAcquire *Owner, /*{{{*/
pkgAcqMetaBase(Owner, IndexTargets, MetaIndexParser, HashStringList(),
TransactionManager),
RealURI(URI), URIDesc(URIDesc), ShortDesc(ShortDesc),
- AuthPass(false), IMSHit(false),
MetaIndexSigURI(MetaIndexSigURI), MetaIndexSigURIDesc(MetaIndexSigURIDesc),
MetaIndexSigShortDesc(MetaIndexSigShortDesc)
{
@@ -1752,9 +1769,9 @@ void pkgAcqMetaIndex::Done(string Message,unsigned long long Size,HashStringList
FinalFile += URItoFileName(RealURI);
if (SigFile == DestFile)
SigFile = FinalFile;
+
// queue for copy in place
- PartialFile = DestFile;
- DestFile = FinalFile;
+ TransactionManager->TransactionStageCopy(this, DestFile, FinalFile);
}
}
/*}}}*/
@@ -2077,8 +2094,7 @@ void pkgAcqMetaIndex::Failed(string Message,
}
// Done, queue for rename on transaction finished
- PartialFile = DestFile;
- DestFile = FinalFile;
+ TransactionManager->TransactionStageCopy(this, DestFile, FinalFile);
}
_error->Warning(_("The data from '%s' is not signed. Packages "
@@ -2197,8 +2213,7 @@ void pkgAcqMetaClearSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /*
// impression (CVE-2012-0214)
string FinalFile = _config->FindDir("Dir::State::lists");
FinalFile.append(URItoFileName(RealURI));
- PartialFile = "";
- DestFile = FinalFile;
+ TransactionManager->TransactionStageRemoval(this, FinalFile);
new pkgAcqMetaIndex(Owner, TransactionManager,
MetaIndexURI, MetaIndexURIDesc, MetaIndexShortDesc,
diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h
index 3c81f77a9..e560da956 100644
--- a/apt-pkg/acquire-item.h
+++ b/apt-pkg/acquire-item.h
@@ -364,6 +364,13 @@ class pkgAcqMetaBase : public pkgAcquire::Item
*/
const std::vector<IndexTarget*>* IndexTargets;
+ /** \brief If \b true, the index's signature is currently being verified.
+ */
+ bool AuthPass;
+
+ // required to deal gracefully with problems caused by incorrect ims hits
+ bool IMSHit;
+
/** \brief Starts downloading the individual index files.
*
* \param verify If \b true, only indices whose expected hashsum
@@ -381,6 +388,15 @@ class pkgAcqMetaBase : public pkgAcquire::Item
bool TransactionHasError() APT_PURE;
void CommitTransaction();
+ /** \brief Stage (queue) a copy action when the transaction is commited
+ */
+ void TransactionStageCopy(Item *I,
+ const std::string &From,
+ const std::string &To);
+ /** \brief Stage (queue) a removal action when the transaction is commited
+ */
+ void TransactionStageRemoval(Item *I, const std::string &FinalFile);
+
// helper for the signature warning
bool GenerateAuthWarning(const std::string &RealURI,
const std::string &Message);
@@ -392,7 +408,8 @@ class pkgAcqMetaBase : public pkgAcquire::Item
HashStringList const &ExpectedHashes=HashStringList(),
pkgAcqMetaBase *TransactionManager=NULL)
: Item(Owner, ExpectedHashes, TransactionManager),
- MetaIndexParser(MetaIndexParser), IndexTargets(IndexTargets) {};
+ MetaIndexParser(MetaIndexParser), IndexTargets(IndexTargets),
+ AuthPass(false), IMSHit(false) {};
};
/** \brief An acquire item that downloads the detached signature {{{
@@ -415,17 +432,14 @@ class pkgAcqMetaSig : public pkgAcqMetaBase
*/
std::string RealURI;
- std::string URIDesc;
- std::string ShortDesc;
-
/** \brief The file we need to verify */
std::string MetaIndexFile;
- /** \brief If we are in fetching or download state */
- bool AuthPass;
+ /** \brief Long URI description used in the acquire system */
+ std::string URIDesc;
- /** \brief Was this file already on disk */
- bool IMSHit;
+ /** \brief Short URI description used in the acquire system */
+ std::string ShortDesc;
public:
@@ -474,12 +488,6 @@ class pkgAcqMetaIndex : public pkgAcqMetaBase
*/
std::string SigFile;
- /** \brief If \b true, the index's signature is currently being verified.
- */
- bool AuthPass;
- // required to deal gracefully with problems caused by incorrect ims hits
- bool IMSHit;
-
/** \brief Check that the release file is a release file for the
* correct distribution.
*