diff options
author | Daniel Hartwig <mandyke@gmail.com> | 2012-04-27 11:37:30 +0800 |
---|---|---|
committer | Daniel Hartwig <mandyke@gmail.com> | 2012-04-27 11:37:30 +0800 |
commit | 7e0943f234c3a84bf5c88057529640a649345ab3 (patch) | |
tree | 6e357cc7a1828dc4582d2475b7bfd6132a72a745 /src | |
parent | 0406ba37b8500013ccafa9f5b08a3e4d1a522f87 (diff) | |
download | aptitude-7e0943f234c3a84bf5c88057529640a649345ab3.tar.gz |
Revert "Update package lists using ListUpdate (libapt-pkg)"
This reverts commit bd3f0ed4935577f5d942b418f11c0a8a50894c7b.
ListUpdate did not fit download_upload_manager well, but appeared
to work. Now reverting in favour of updating the local code and
hopefully this allows us to tackle some of the bugs that popped up.
Diffstat (limited to 'src')
-rw-r--r-- | src/generic/apt/download_update_manager.cc | 72 | ||||
-rw-r--r-- | src/generic/apt/download_update_manager.h | 4 |
2 files changed, 52 insertions, 24 deletions
diff --git a/src/generic/apt/download_update_manager.cc b/src/generic/apt/download_update_manager.cc index c7f3f582..8e6e789b 100644 --- a/src/generic/apt/download_update_manager.cc +++ b/src/generic/apt/download_update_manager.cc @@ -27,7 +27,6 @@ #include <apt-pkg/cachefile.h> #include <apt-pkg/clean.h> #include <apt-pkg/error.h> -#include <apt-pkg/algorithms.h> #include <cwidget/generic/util/exception.h> #include <cwidget/generic/util/ssprintf.h> @@ -79,8 +78,6 @@ bool download_update_manager::prepare(OpProgress &progress, return false; } - stat = &acqlog; - // Abort here so we don't spew random messages below. if(_error->PendingError()) return false; @@ -97,23 +94,17 @@ bool download_update_manager::prepare(OpProgress &progress, } } - return true; -} - -pkgAcquire::RunResult download_update_manager::do_download() -{ - if(ListUpdate(*stat, src_list) == false) - return pkgAcquire::Failed; + fetcher = new pkgAcquire(); + fetcher->Setup(&acqlog); - return pkgAcquire::Continue; -} - -pkgAcquire::RunResult download_update_manager::do_download(int PulseInterval) -{ - if(ListUpdate(*stat, src_list, PulseInterval) == false) - return pkgAcquire::Failed; - - return pkgAcquire::Continue; + if(!src_list.GetIndexes(fetcher)) + { + delete fetcher; + fetcher = NULL; + return false; + } + else + return true; } // TODO: this should be lifted to generic code. @@ -292,6 +283,46 @@ void download_update_manager::finish(pkgAcquire::RunResult res, return; } + bool transientNetworkFailure = false; + result rval = success; + + // We need to claim that the download failed if any source failed, + // and invoke Finished() on any failed items. Also, we shouldn't + // clean the package lists if any individual item failed because it + // makes users grumpy (see Debian bugs #201842 and #479620). + // + // See also apt-get.cc. + for(pkgAcquire::ItemIterator it = fetcher->ItemsBegin(); + it != fetcher->ItemsEnd(); ++it) + { + if((*it)->Status == pkgAcquire::Item::StatDone) + continue; + + (*it)->Finished(); + + if((*it)->Status == pkgAcquire::Item::StatTransientNetworkError) + { + transientNetworkFailure = true; + continue; + } + + // Q: should I display an error message for this source? + rval = failure; + } + + // Clean old stuff out + std::string listsdir = aptcfg->FindDir("Dir::State::lists"); + if(rval == success && !transientNetworkFailure && + aptcfg->FindB("APT::Get::List-Cleanup", true) == true && + aptcfg->FindB("APT::List-Cleanup", true) == true && + (fetcher->Clean(listsdir) == false || + fetcher->Clean(listsdir + "partial/") == false)) + { + _error->Error(_("Couldn't clean out list directories")); + k(failure); + return; + } + // Rebuild the apt caches as done in apt-get. cachefile is scoped // so it dies before we possibly-reload the cache. This will do a // little redundant work in visual mode, but avoids lots of @@ -300,6 +331,7 @@ void download_update_manager::finish(pkgAcquire::RunResult res, pkgCacheFile cachefile; if(!cachefile.BuildCaches(progress, true)) { + _error->Error(_("Couldn't rebuild package cache")); k(failure); return; } @@ -408,7 +440,7 @@ void download_update_manager::finish(pkgAcquire::RunResult res, post_autoclean_hook(); } - k(success); + k(rval); return; } diff --git a/src/generic/apt/download_update_manager.h b/src/generic/apt/download_update_manager.h index 87f69505..378bb9f7 100644 --- a/src/generic/apt/download_update_manager.h +++ b/src/generic/apt/download_update_manager.h @@ -38,7 +38,6 @@ class download_update_manager : public download_manager download_signal_log *log; pkgSourceList src_list; - pkgAcquireStatus *stat; public: /** Create a new manager. Note that acqlog and signallog may or may @@ -72,9 +71,6 @@ public: pkgAcquireStatus &acqlog, download_signal_log *signallog); - pkgAcquire::RunResult do_download(); - pkgAcquire::RunResult do_download(int PulseInterval); - void finish(pkgAcquire::RunResult res, OpProgress *progress, const sigc::slot1<void, result> &k); |