summaryrefslogtreecommitdiff
path: root/payload_state.cc
diff options
context:
space:
mode:
Diffstat (limited to 'payload_state.cc')
-rw-r--r--payload_state.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/payload_state.cc b/payload_state.cc
index 2e07ad97..cf3aab91 100644
--- a/payload_state.cc
+++ b/payload_state.cc
@@ -312,6 +312,7 @@ void PayloadState::UpdateFailed(ErrorCode error) {
case ErrorCode::kUnsupportedMinorPayloadVersion:
case ErrorCode::kPayloadTimestampError:
case ErrorCode::kVerityCalculationError:
+ ExcludeCurrentPayload();
IncrementUrlIndex();
break;
@@ -502,10 +503,29 @@ void PayloadState::IncrementFailureCount() {
} else {
LOG(INFO) << "Reached max number of failures for Url" << GetUrlIndex()
<< ". Trying next available URL";
+ ExcludeCurrentPayload();
IncrementUrlIndex();
}
}
+void PayloadState::ExcludeCurrentPayload() {
+ const auto& package = response_.packages[payload_index_];
+ if (!package.can_exclude) {
+ LOG(INFO) << "Not excluding as marked non-excludable for package hash="
+ << package.hash;
+ return;
+ }
+ auto exclusion_name = utils::GetExclusionName(GetCurrentUrl());
+ if (!excluder_->Exclude(exclusion_name))
+ LOG(WARNING) << "Failed to exclude "
+ << " Package Hash=" << package.hash
+ << " CurrentUrl=" << GetCurrentUrl();
+ else
+ LOG(INFO) << "Excluded "
+ << " Package Hash=" << package.hash
+ << " CurrentUrl=" << GetCurrentUrl();
+}
+
void PayloadState::UpdateBackoffExpiryTime() {
if (response_.disable_payload_backoff) {
LOG(INFO) << "Resetting backoff expiry time as payload backoff is disabled";