diff options
author | Michael Vogt <mvo@ubuntu.com> | 2014-07-18 23:41:29 +0200 |
---|---|---|
committer | Michael Vogt <mvo@ubuntu.com> | 2014-07-21 08:17:17 +0200 |
commit | 47aca3cfc17ee23c37693b4e53c675a74b38decd (patch) | |
tree | 8112560d31700e67429e0a2a4a479e22cd63d424 /apt-pkg | |
parent | 564720959e4ae47921b795fe6c5ce46e1e1bdc95 (diff) |
add pkgAcquire::TransactionHasError()
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/acquire-item.cc | 7 | ||||
-rw-r--r-- | apt-pkg/acquire.cc | 23 | ||||
-rw-r--r-- | apt-pkg/acquire.h | 1 |
3 files changed, 25 insertions, 6 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index bd11ba66c..81afdf4b1 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -1421,12 +1421,12 @@ void pkgAcqMetaSig::Done(string Message,unsigned long long Size, HashStringList DestFile += URItoFileName(RealURI); // queue a pkgAcqMetaIndex to be verified against the sig we just retrieved - pkgAcqMetaIndex *mi = new pkgAcqMetaIndex( + pkgAcqMetaIndex *metaindex = new pkgAcqMetaIndex( Owner, MetaIndexURI, MetaIndexURIDesc, MetaIndexShortDesc, DestFile, IndexTargets, MetaIndexParser); - TransactionID = (unsigned long)mi; + TransactionID = (unsigned long)metaindex; } /*}}}*/ void pkgAcqMetaSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf)/*{{{*/ @@ -1908,7 +1908,8 @@ void pkgAcqMetaIndex::Finished() { if(_config->FindB("Debug::Acquire::Transaction", false) == true) std::clog << "Finished: " << DestFile <<std::endl; - Owner->CommitTransaction((unsigned long)this); + if(Owner->TransactionHasError((unsigned long)this) == false) + Owner->CommitTransaction((unsigned long)this); } diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 2e2e39d51..4b82fa46d 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -185,11 +185,21 @@ void pkgAcquire::AbortTransaction(unsigned long TransactionID) { if(_config->FindB("Debug::Acquire::Transaction", false) == true) std::clog << " Cancel: " << (*I)->DestFile << std::endl; - Dequeue(*I); + //Dequeue(*I); (*I)->Status = pkgAcquire::Item::StatError; } } /*}}}*/ +bool pkgAcquire::TransactionHasError(unsigned long TransactionID) +{ + std::vector<Item*> Transaction; + for (ItemIterator I = Items.begin(); I != Items.end(); ++I) + if((*I)->TransactionID == TransactionID) + if((*I)->Status == pkgAcquire::Item::StatError || + (*I)->Status == pkgAcquire::Item::StatAuthError) + return true; + return false; +} // Acquire::CommitTransaction - Commit a transaction /*{{{*/ void pkgAcquire::CommitTransaction(unsigned long TransactionID) { @@ -201,18 +211,25 @@ void pkgAcquire::CommitTransaction(unsigned long TransactionID) if((*I)->TransactionID == TransactionID) Transaction.push_back(*I); + // move new files into place *and* remove files that are not + // part of the transaction but are still on disk for (std::vector<Item*>::iterator I = Transaction.begin(); I != Transaction.end(); ++I) { - if((*I)->PartialFile != "" && - (*I)->Status == pkgAcquire::Item::StatDone) + if((*I)->PartialFile != "") { if(_config->FindB("Debug::Acquire::Transaction", false) == true) std::clog << "mv " << (*I)->PartialFile << " -> " << (*I)->DestFile << std::endl; + Rename((*I)->PartialFile, (*I)->DestFile); chmod((*I)->DestFile.c_str(),0644); + } else { + if(_config->FindB("Debug::Acquire::Transaction", false) == true) + std::clog << "rm " + << (*I)->DestFile << std::endl; + unlink((*I)->DestFile.c_str()); } } } diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index 0b955cc76..7f51dd8f5 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -251,6 +251,7 @@ class pkgAcquire /** \brief Abort a given transaction */ void AbortTransaction(unsigned long TransactionID); void CommitTransaction(unsigned long TransactionID); + bool TransactionHasError(unsigned long TransactionID); /** \brief Retrieve information about a fetch method by name. * |