Resume multiple payloads.
DownloadAction will first go through all the already applied payload
and only downloading the manifest and filling in partitions info in
install plan without applying or downloading any operations.
And then resume the partially applied payload using states in prefs.
Moved constuction of MultiRangeHttpFetcher from UpdateAttempter to
DownloadAction, because we now need to setup the range for every
payload, also reduced code duplication.
Also fixed download progress for multi payload.
Bug: 36252799
Test: stop an update during second payload and resume the update
Change-Id: I9ee54a87d15d88c7a14a13575965b19c1773340b
(cherry picked from commit 7162b666318cdd6c75b73fa6a0b06b23559de3e5)
diff --git a/update_attempter.cc b/update_attempter.cc
index 448e29c..ff3b046 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -45,7 +45,6 @@
#include "update_engine/common/clock_interface.h"
#include "update_engine/common/constants.h"
#include "update_engine/common/hardware_interface.h"
-#include "update_engine/common/multi_range_http_fetcher.h"
#include "update_engine/common/platform_constants.h"
#include "update_engine/common/prefs_interface.h"
#include "update_engine/common/subprocess.h"
@@ -619,12 +618,12 @@
LibcurlHttpFetcher* download_fetcher =
new LibcurlHttpFetcher(GetProxyResolver(), system_state_->hardware());
download_fetcher->set_server_to_check(ServerToCheck::kDownload);
- shared_ptr<DownloadAction> download_action(new DownloadAction(
- prefs_,
- system_state_->boot_control(),
- system_state_->hardware(),
- system_state_,
- new MultiRangeHttpFetcher(download_fetcher))); // passes ownership
+ shared_ptr<DownloadAction> download_action(
+ new DownloadAction(prefs_,
+ system_state_->boot_control(),
+ system_state_->hardware(),
+ system_state_,
+ download_fetcher)); // passes ownership
shared_ptr<OmahaRequestAction> download_finished_action(
new OmahaRequestAction(
system_state_,
@@ -1038,7 +1037,6 @@
new_payload_size_ = 0;
for (const auto& payload : plan.payloads)
new_payload_size_ += payload.size;
- SetupDownload();
cpu_limiter_.StartLimiter();
SetStatusAndNotify(UpdateStatus::UPDATE_AVAILABLE);
} else if (type == DownloadAction::StaticType()) {
@@ -1326,35 +1324,6 @@
prefs_->SetInt64(kPrefsDeltaUpdateFailures, ++delta_failures);
}
-void UpdateAttempter::SetupDownload() {
- MultiRangeHttpFetcher* fetcher =
- static_cast<MultiRangeHttpFetcher*>(download_action_->http_fetcher());
- fetcher->ClearRanges();
- if (response_handler_action_->install_plan().is_resume) {
- // Resuming an update so fetch the update manifest metadata first.
- int64_t manifest_metadata_size = 0;
- int64_t manifest_signature_size = 0;
- prefs_->GetInt64(kPrefsManifestMetadataSize, &manifest_metadata_size);
- prefs_->GetInt64(kPrefsManifestSignatureSize, &manifest_signature_size);
- fetcher->AddRange(0, manifest_metadata_size + manifest_signature_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);
- uint64_t resume_offset =
- manifest_metadata_size + manifest_signature_size + next_data_offset;
- int64_t payload_index = 0;
- prefs_->GetInt64(kPrefsUpdateStatePayloadIndex, &payload_index);
- if (resume_offset <
- response_handler_action_->install_plan().payloads[payload_index].size) {
- fetcher->AddRange(resume_offset);
- }
- } else {
- fetcher->AddRange(0);
- }
-}
-
void UpdateAttempter::PingOmaha() {
if (!processor_->IsRunning()) {
shared_ptr<OmahaRequestAction> ping_action(new OmahaRequestAction(