-
// Include Files /*{{{*/
#include <config.h>
-#include <apt-pkg/algorithms.h>
-#include <apt-pkg/update.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/configuration.h>
-#include <apt-pkg/version.h>
-#include <apt-pkg/sptr.h>
#include <apt-pkg/acquire-item.h>
-#include <apt-pkg/edsp.h>
-#include <apt-pkg/sourcelist.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/progress.h>
+#include <apt-pkg/sourcelist.h>
+#include <apt-pkg/acquire.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/update.h>
-#include <sys/types.h>
-#include <cstdlib>
-#include <algorithm>
-#include <iostream>
-#include <stdio.h>
+#include <string>
#include <apti18n.h>
/*}}}*/
pkgSourceList &List,
int PulseInterval)
{
- pkgAcquire Fetcher;
- if (Fetcher.Setup(&Stat, _config->FindDir("Dir::State::Lists")) == false)
+ pkgAcquire Fetcher(&Stat);
+ if (Fetcher.GetLock(_config->FindDir("Dir::State::Lists")) == false)
return false;
// Populate it with the source selection
bool Failed = false;
bool TransientNetworkFailure = false;
+ bool AllFailed = true;
for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin();
I != Fetcher.ItemsEnd(); ++I)
{
- if ((*I)->Status == pkgAcquire::Item::StatDone)
+ if ((*I)->Status == pkgAcquire::Item::StatDone) {
+ AllFailed = false;
continue;
+ }
(*I)->Finished();
uri.User.clear();
uri.Password.clear();
string descUri = string(uri);
- _error->Warning(_("Failed to fetch %s %s\n"), descUri.c_str(),
- (*I)->ErrorText.c_str());
-
+ // Show an error for non-transient failures, otherwise only warn
+ if ((*I)->Status == pkgAcquire::Item::StatTransientNetworkError)
+ _error->Warning(_("Failed to fetch %s %s"), descUri.c_str(),
+ (*I)->ErrorText.c_str());
+ else
+ _error->Error(_("Failed to fetch %s %s"), descUri.c_str(),
+ (*I)->ErrorText.c_str());
if ((*I)->Status == pkgAcquire::Item::StatTransientNetworkError)
{
TransientNetworkFailure = true;
// something went wrong with the clean
return false;
}
+
+ bool Res = true;
if (TransientNetworkFailure == true)
- _error->Warning(_("Some index files failed to download. They have been ignored, or old ones used instead."));
+ Res = _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."));
+ Res = _error->Error(_("Some index files failed to download. They have been ignored, or old ones used instead."));
// Run the success scripts if all was fine
if (RunUpdateScripts == true)
{
- if(!TransientNetworkFailure && !Failed)
+ if(AllFailed == false)
RunScripts("APT::Update::Post-Invoke-Success");
// Run the other scripts
RunScripts("APT::Update::Post-Invoke");
}
- return true;
+ return Res;
}
/*}}}*/