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