diff options
author | Michael Vogt <mvo@ubuntu.com> | 2014-07-18 23:21:46 +0200 |
---|---|---|
committer | Michael Vogt <mvo@ubuntu.com> | 2014-07-18 23:21:46 +0200 |
commit | 564720959e4ae47921b795fe6c5ce46e1e1bdc95 (patch) | |
tree | abaa12f1cee1cceadc11cd98a7b2352a1fce0af2 /apt-pkg/acquire.cc | |
parent | 9c3e15ab5f8b5864c43a08065a6bc8cf376fd138 (diff) |
WIP transaction based update
Diffstat (limited to 'apt-pkg/acquire.cc')
-rw-r--r-- | apt-pkg/acquire.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 8467dab5b..2e2e39d51 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -37,6 +37,7 @@ #include <sys/time.h> #include <sys/select.h> #include <errno.h> +#include <sys/stat.h> #include <apti18n.h> /*}}}*/ @@ -168,6 +169,55 @@ void pkgAcquire::Remove(Item *Itm) } } /*}}}*/ +// Acquire::AbortTransaction - Remove a transaction /*{{{*/ +void pkgAcquire::AbortTransaction(unsigned long TransactionID) +{ + if(_config->FindB("Debug::Acquire::Transaction", false) == true) + std::clog << "AbortTransaction: " << TransactionID << std::endl; + + std::vector<Item*> Transaction; + for (ItemIterator I = Items.begin(); I != Items.end(); ++I) + if((*I)->TransactionID == TransactionID) + Transaction.push_back(*I); + + for (std::vector<Item*>::iterator I = Transaction.begin(); + I != Transaction.end(); ++I) + { + if(_config->FindB("Debug::Acquire::Transaction", false) == true) + std::clog << " Cancel: " << (*I)->DestFile << std::endl; + Dequeue(*I); + (*I)->Status = pkgAcquire::Item::StatError; + } +} + /*}}}*/ +// Acquire::CommitTransaction - Commit a transaction /*{{{*/ +void pkgAcquire::CommitTransaction(unsigned long TransactionID) +{ + if(_config->FindB("Debug::Acquire::Transaction", false) == true) + std::clog << "CommitTransaction: " << TransactionID << std::endl; + + std::vector<Item*> Transaction; + for (ItemIterator I = Items.begin(); I != Items.end(); ++I) + if((*I)->TransactionID == TransactionID) + Transaction.push_back(*I); + + for (std::vector<Item*>::iterator I = Transaction.begin(); + I != Transaction.end(); ++I) + { + if((*I)->PartialFile != "" && + (*I)->Status == pkgAcquire::Item::StatDone) + { + 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); + } + } +} + /*}}}*/ + // Acquire::Add - Add a worker /*{{{*/ // --------------------------------------------------------------------- /* A list of workers is kept so that the select loop can direct their FD |