Index: update_attempter.cc |
diff --git a/update_attempter.cc b/update_attempter.cc |
index 1e3bf5db730f252134479075dbd843ff44e61c5b..7c324755aa328e3c97f108c637ca086ed65572f8 100644 |
--- a/update_attempter.cc |
+++ b/update_attempter.cc |
@@ -535,12 +535,19 @@ void UpdateAttempter::SetupDownload() { |
download_action_->http_fetcher()); |
MultiHttpFetcher<LibcurlHttpFetcher>::RangesVect ranges; |
if (response_handler_action_->install_plan().is_resume) { |
+ // Resuming an update so fetch the update manifest metadata first. |
int64_t manifest_metadata_size = 0; |
prefs_->GetInt64(kPrefsManifestMetadataSize, &manifest_metadata_size); |
+ ranges.push_back(make_pair(0, manifest_metadata_size)); |
+ // If there're remaining unprocessed data blobs, fetch them. Be careful not |
+ // to request data beyond the end of the payload to avoid 416 HTTP response |
+ // error codes. |
int64_t next_data_offset = 0; |
prefs_->GetInt64(kPrefsUpdateStateNextDataOffset, &next_data_offset); |
- ranges.push_back(make_pair(0, manifest_metadata_size)); |
- ranges.push_back(make_pair(manifest_metadata_size + next_data_offset, -1)); |
+ uint64_t resume_offset = manifest_metadata_size + next_data_offset; |
+ if (resume_offset < response_handler_action_->install_plan().size) { |
+ ranges.push_back(make_pair(resume_offset, -1)); |
+ } |
} else { |
ranges.push_back(make_pair(0, -1)); |
} |