| OLD | NEW |
| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 ActionExitCode code = | 140 ActionExitCode code = |
| 141 successful ? kActionCodeSuccess : kActionCodeDownloadTransferError; | 141 successful ? kActionCodeSuccess : kActionCodeDownloadTransferError; |
| 142 if (code == kActionCodeSuccess) { | 142 if (code == kActionCodeSuccess) { |
| 143 if (!install_plan_.is_full_update) { | 143 if (!install_plan_.is_full_update) { |
| 144 if (!delta_performer_->VerifyPayload("", | 144 if (!delta_performer_->VerifyPayload("", |
| 145 install_plan_.download_hash, | 145 install_plan_.download_hash, |
| 146 install_plan_.size)) { | 146 install_plan_.size)) { |
| 147 LOG(ERROR) << "Download of " << install_plan_.download_url | 147 LOG(ERROR) << "Download of " << install_plan_.download_url |
| 148 << " failed due to payload verification error."; | 148 << " failed due to payload verification error."; |
| 149 code = kActionCodeDownloadPayloadVerificationError; | 149 code = kActionCodeDownloadPayloadVerificationError; |
| 150 } else if (!delta_performer_->VerifyAppliedUpdate( |
| 151 install_plan_.install_path, install_plan_.kernel_install_path)) { |
| 152 LOG(ERROR) << "Download of " << install_plan_.download_url |
| 153 << " failed due to applied update verification error."; |
| 154 code = kActionCodeDownloadAppliedUpdateVerificationError; |
| 150 } | 155 } |
| 151 } else { | 156 } else { |
| 152 // Makes sure the hash and size are correct for an old-style full update. | 157 // Makes sure the hash and size are correct for an old-style full update. |
| 153 omaha_hash_calculator_.Finalize(); | 158 omaha_hash_calculator_.Finalize(); |
| 154 if (omaha_hash_calculator_.hash() != install_plan_.download_hash) { | 159 if (omaha_hash_calculator_.hash() != install_plan_.download_hash) { |
| 155 LOG(ERROR) << "Download of " << install_plan_.download_url | 160 LOG(ERROR) << "Download of " << install_plan_.download_url |
| 156 << " failed. Expected hash " << install_plan_.download_hash | 161 << " failed. Expected hash " << install_plan_.download_hash |
| 157 << " but got hash " << omaha_hash_calculator_.hash(); | 162 << " but got hash " << omaha_hash_calculator_.hash(); |
| 158 code = kActionCodeDownloadHashMismatchError; | 163 code = kActionCodeDownloadHashMismatchError; |
| 159 } else if (bytes_received_ != install_plan_.size) { | 164 } else if (bytes_received_ != install_plan_.size) { |
| 160 LOG(ERROR) << "Download of " << install_plan_.download_url | 165 LOG(ERROR) << "Download of " << install_plan_.download_url |
| 161 << " failed. Expected size " << install_plan_.size | 166 << " failed. Expected size " << install_plan_.size |
| 162 << " but got size " << bytes_received_; | 167 << " but got size " << bytes_received_; |
| 163 code = kActionCodeDownloadSizeMismatchError; | 168 code = kActionCodeDownloadSizeMismatchError; |
| 164 } | 169 } |
| 165 } | 170 } |
| 166 } | 171 } |
| 167 | 172 |
| 168 FlushLinuxCaches(); | 173 FlushLinuxCaches(); |
| 169 | 174 |
| 170 // Write the path to the output pipe if we're successful. | 175 // Write the path to the output pipe if we're successful. |
| 171 if (code == kActionCodeSuccess && HasOutputPipe()) | 176 if (code == kActionCodeSuccess && HasOutputPipe()) |
| 172 SetOutputObject(GetInputObject()); | 177 SetOutputObject(GetInputObject()); |
| 173 processor_->ActionComplete(this, code); | 178 processor_->ActionComplete(this, code); |
| 174 } | 179 } |
| 175 | 180 |
| 176 }; // namespace {} | 181 }; // namespace {} |
| OLD | NEW |