diff options
author | Julian Andres Klode <julian.klode@canonical.com> | 2021-01-08 17:52:53 +0100 |
---|---|---|
committer | Julian Andres Klode <julian.klode@canonical.com> | 2021-01-08 17:58:44 +0100 |
commit | c7123bea6a8dc2c9e327ce41ddfc25e29f1bb145 (patch) | |
tree | 979d87e4f479100dda85f65452eba90fb4053b41 /apt-pkg | |
parent | d35d51ddbdc75512a73e713972f4bbb5a1fd73ae (diff) |
Implement update --error-on=any
People have been asking for a feature to error out on transient network
errors for a while, this gives them one while keeping the door open for
other modes we need, such as --error-on=no-success which we need to
determine when to retry the daily update job.
Closes: #594813
(and a whole bunch of duplicates...)
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/update.cc | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/apt-pkg/update.cc b/apt-pkg/update.cc index 1b25bafd6..1bf818ad7 100644 --- a/apt-pkg/update.cc +++ b/apt-pkg/update.cc @@ -46,6 +46,20 @@ bool ListUpdate(pkgAcquireStatus &Stat, bool AcquireUpdate(pkgAcquire &Fetcher, int const PulseInterval, bool const RunUpdateScripts, bool const ListCleanup) { + enum class ErrorMode + { + Persistent, + Any + }; + std::string errorModeS = _config->Find("APT::Update::Error-Mode", "persistent"); + ErrorMode errorMode = ErrorMode::Persistent; + if (errorModeS == "persistent") + errorMode = ErrorMode::Persistent; + else if (errorModeS == "any") + errorMode = ErrorMode::Any; + else + return _error->Error("Unknown update error mode %s", errorModeS.c_str()); + // Run scripts if (RunUpdateScripts == true) RunScripts("APT::Update::Pre-Invoke"); @@ -69,7 +83,10 @@ bool AcquireUpdate(pkgAcquire &Fetcher, int const PulseInterval, AllFailed = false; continue; case pkgAcquire::Item::StatTransientNetworkError: - TransientNetworkFailure = true; + if (errorMode == ErrorMode::Any) + Failed = true; + else + TransientNetworkFailure = true; break; case pkgAcquire::Item::StatIdle: case pkgAcquire::Item::StatFetching: @@ -91,7 +108,7 @@ bool AcquireUpdate(pkgAcquire &Fetcher, int const PulseInterval, uri.Path = DeQuoteString(uri.Path); std::string const descUri = std::string(uri); // Show an error for non-transient failures, otherwise only warn - if ((*I)->Status == pkgAcquire::Item::StatTransientNetworkError) + if ((*I)->Status == pkgAcquire::Item::StatTransientNetworkError && errorMode != ErrorMode::Any) _error->Warning(_("Failed to fetch %s %s"), descUri.c_str(), (*I)->ErrorText.c_str()); else |