diff options
Diffstat (limited to 'apt-pkg/cachefile.cc')
-rw-r--r-- | apt-pkg/cachefile.cc | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc index 8b8e6dc98..4c2c56893 100644 --- a/apt-pkg/cachefile.cc +++ b/apt-pkg/cachefile.cc @@ -12,10 +12,6 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#ifdef __GNUG__ -#pragma implementation "apt-pkg/cachefile.h" -#endif - #include <apt-pkg/cachefile.h> #include <apt-pkg/error.h> #include <apt-pkg/sourcelist.h> @@ -115,7 +111,9 @@ bool pkgCacheFile::Open(OpProgress &Progress,bool WithLock) // CacheFile::ListUpdate - update the cache files /*{{{*/ // --------------------------------------------------------------------- -/* */ +/* This is a simple wrapper to update the cache. it will fetch stuff + * from the network (or any other sources defined in sources.list) + */ bool pkgCacheFile::ListUpdate(pkgAcquireStatus &Stat, pkgSourceList &List) { pkgAcquire Fetcher(&Stat); @@ -123,43 +121,58 @@ bool pkgCacheFile::ListUpdate(pkgAcquireStatus &Stat, pkgSourceList &List) // Populate it with the source selection if (List.GetIndexes(&Fetcher) == false) return false; - + // Run scripts RunScripts("APT::Update::Pre-Invoke"); - + // Run it if (Fetcher.Run() == pkgAcquire::Failed) return false; bool Failed = false; - for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++) + bool TransientNetworkFailure = false; + for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); + I != Fetcher.ItemsEnd(); I++) { if ((*I)->Status == pkgAcquire::Item::StatDone) continue; (*I)->Finished(); - - _error->Warning(_("Failed to fetch %s %s\n"), - (*I)->DescURI().c_str(), - (*I)->ErrorText.c_str()); + + fprintf(stderr,_("Failed to fetch %s %s\n"),(*I)->DescURI().c_str(), + (*I)->ErrorText.c_str()); + + if ((*I)->Status == pkgAcquire::Item::StatTransientNetworkError) + { + TransientNetworkFailure = true; + continue; + } + Failed = true; } - - // Clean out any old list files (if it was not a failure) + + // Clean out any old list files // Keep "APT::Get::List-Cleanup" name for compatibility, but // this is really a global option for the APT library now - if (!Failed && (_config->FindB("APT::Get::List-Cleanup",true) == true || - _config->FindB("APT::List-Cleanup",true) == true)) + if (!TransientNetworkFailure && !Failed && + (_config->FindB("APT::Get::List-Cleanup",true) == true || + _config->FindB("APT::List-Cleanup",true) == true)) { if (Fetcher.Clean(_config->FindDir("Dir::State::lists")) == false || Fetcher.Clean(_config->FindDir("Dir::State::lists") + "partial/") == false) + // something went wrong with the clean return false; } + + if (TransientNetworkFailure == true) + _error->Warning(_("Some index files failed to download, they have been ignored, or old ones used instead.")); + else if (Failed == true) + return _error->Error(_("Some index files failed to download, they have been ignored, or old ones used instead.")); - // Run the scripts - RunScripts("APT::Update::Post-Invoke"); - return (Failed == false); + // Run the scripts if all was fine + RunScripts("APT::Update::Post-Invoke"); + return true; } /*}}}*/ |