Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: download_action.cc

Issue 5516009: AU: Split applied update verification into a separate step. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git@master
Patch Set: review comments Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « delta_performer_unittest.cc ('k') | filesystem_copier_action.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "update_engine/download_action.h" 5 #include "update_engine/download_action.h"
6 #include <errno.h> 6 #include <errno.h>
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 #include <glib.h> 10 #include <glib.h>
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 rootfs_buffered_file_writer_.get())); 58 rootfs_buffered_file_writer_.get()));
59 split_file_writer_->SetFirstOpenArgs( 59 split_file_writer_->SetFirstOpenArgs(
60 install_plan_.kernel_install_path.c_str(), 60 install_plan_.kernel_install_path.c_str(),
61 O_WRONLY | O_CREAT | O_TRUNC | O_LARGEFILE, 61 O_WRONLY | O_CREAT | O_TRUNC | O_LARGEFILE,
62 0644); 62 0644);
63 decompressing_file_writer_.reset( 63 decompressing_file_writer_.reset(
64 new GzipDecompressingFileWriter(split_file_writer_.get())); 64 new GzipDecompressingFileWriter(split_file_writer_.get()));
65 writer_ = decompressing_file_writer_.get(); 65 writer_ = decompressing_file_writer_.get();
66 } else { 66 } else {
67 delta_performer_.reset(new DeltaPerformer(prefs_)); 67 delta_performer_.reset(new DeltaPerformer(prefs_));
68 delta_performer_->set_current_kernel_hash( 68 delta_performer_->set_current_kernel_hash(install_plan_.kernel_hash);
69 &install_plan_.current_kernel_hash); 69 delta_performer_->set_current_rootfs_hash(install_plan_.rootfs_hash);
70 delta_performer_->set_current_rootfs_hash(
71 &install_plan_.current_rootfs_hash);
72 writer_ = delta_performer_.get(); 70 writer_ = delta_performer_.get();
73 } 71 }
74 } 72 }
75 int rc = writer_->Open(install_plan_.install_path.c_str(), 73 int rc = writer_->Open(install_plan_.install_path.c_str(),
76 O_TRUNC | O_WRONLY | O_CREAT | O_LARGEFILE, 74 O_TRUNC | O_WRONLY | O_CREAT | O_LARGEFILE,
77 0644); 75 0644);
78 if (rc < 0) { 76 if (rc < 0) {
79 LOG(ERROR) << "Unable to open output file " << install_plan_.install_path; 77 LOG(ERROR) << "Unable to open output file " << install_plan_.install_path;
80 // report error to processor 78 // report error to processor
81 processor_->ActionComplete(this, kActionCodeInstallDeviceOpenError); 79 processor_->ActionComplete(this, kActionCodeInstallDeviceOpenError);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 ActionExitCode code = 160 ActionExitCode code =
163 successful ? kActionCodeSuccess : kActionCodeDownloadTransferError; 161 successful ? kActionCodeSuccess : kActionCodeDownloadTransferError;
164 if (code == kActionCodeSuccess) { 162 if (code == kActionCodeSuccess) {
165 if (!install_plan_.is_full_update) { 163 if (!install_plan_.is_full_update) {
166 if (!delta_performer_->VerifyPayload("", 164 if (!delta_performer_->VerifyPayload("",
167 install_plan_.download_hash, 165 install_plan_.download_hash,
168 install_plan_.size)) { 166 install_plan_.size)) {
169 LOG(ERROR) << "Download of " << install_plan_.download_url 167 LOG(ERROR) << "Download of " << install_plan_.download_url
170 << " failed due to payload verification error."; 168 << " failed due to payload verification error.";
171 code = kActionCodeDownloadPayloadVerificationError; 169 code = kActionCodeDownloadPayloadVerificationError;
172 } else if (!delta_performer_->VerifyAppliedUpdate( 170 } else if (!delta_performer_->GetNewPartitionInfo(
173 install_plan_.install_path, install_plan_.kernel_install_path)) { 171 &install_plan_.kernel_size,
174 LOG(ERROR) << "Download of " << install_plan_.download_url 172 &install_plan_.kernel_hash,
175 << " failed due to applied update verification error."; 173 &install_plan_.rootfs_size,
176 code = kActionCodeDownloadAppliedUpdateVerificationError; 174 &install_plan_.rootfs_hash)) {
175 LOG(ERROR) << "Unable to get new partition hash info.";
176 code = kActionCodeDownloadNewPartitionInfoError;
177 } 177 }
178 } else { 178 } else {
179 // Makes sure the hash and size are correct for an old-style full update. 179 // Makes sure the hash and size are correct for an old-style full update.
180 omaha_hash_calculator_.Finalize(); 180 omaha_hash_calculator_.Finalize();
181 if (omaha_hash_calculator_.hash() != install_plan_.download_hash) { 181 if (omaha_hash_calculator_.hash() != install_plan_.download_hash) {
182 LOG(ERROR) << "Download of " << install_plan_.download_url 182 LOG(ERROR) << "Download of " << install_plan_.download_url
183 << " failed. Expected hash " << install_plan_.download_hash 183 << " failed. Expected hash " << install_plan_.download_hash
184 << " but got hash " << omaha_hash_calculator_.hash(); 184 << " but got hash " << omaha_hash_calculator_.hash();
185 code = kActionCodeDownloadHashMismatchError; 185 code = kActionCodeDownloadHashMismatchError;
186 } else if (bytes_received_ != install_plan_.size) { 186 } else if (bytes_received_ != install_plan_.size) {
187 LOG(ERROR) << "Download of " << install_plan_.download_url 187 LOG(ERROR) << "Download of " << install_plan_.download_url
188 << " failed. Expected size " << install_plan_.size 188 << " failed. Expected size " << install_plan_.size
189 << " but got size " << bytes_received_; 189 << " but got size " << bytes_received_;
190 code = kActionCodeDownloadSizeMismatchError; 190 code = kActionCodeDownloadSizeMismatchError;
191 } 191 }
192 } 192 }
193 } 193 }
194 194
195 FlushLinuxCaches(); 195 FlushLinuxCaches();
196 196
197 // Write the path to the output pipe if we're successful. 197 // Write the path to the output pipe if we're successful.
198 if (code == kActionCodeSuccess && HasOutputPipe()) 198 if (code == kActionCodeSuccess && HasOutputPipe())
199 SetOutputObject(GetInputObject()); 199 SetOutputObject(install_plan_);
200 processor_->ActionComplete(this, code); 200 processor_->ActionComplete(this, code);
201 } 201 }
202 202
203 void DownloadAction::TransferTerminated(HttpFetcher *fetcher) { 203 void DownloadAction::TransferTerminated(HttpFetcher *fetcher) {
204 if (code_ != kActionCodeSuccess) { 204 if (code_ != kActionCodeSuccess) {
205 processor_->ActionComplete(this, code_); 205 processor_->ActionComplete(this, code_);
206 } 206 }
207 } 207 }
208 208
209 }; // namespace {} 209 }; // namespace {}
OLDNEW
« no previous file with comments | « delta_performer_unittest.cc ('k') | filesystem_copier_action.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698