| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 if (writer_) { | 131 if (writer_) { |
| 132 CHECK_EQ(writer_->Close(), 0) << errno; | 132 CHECK_EQ(writer_->Close(), 0) << errno; |
| 133 writer_ = NULL; | 133 writer_ = NULL; |
| 134 } | 134 } |
| 135 if (delegate_) { | 135 if (delegate_) { |
| 136 delegate_->SetDownloadStatus(false); // Set to inactive. | 136 delegate_->SetDownloadStatus(false); // Set to inactive. |
| 137 } | 137 } |
| 138 ActionExitCode code = | 138 ActionExitCode code = |
| 139 successful ? kActionCodeSuccess : kActionCodeDownloadTransferError; | 139 successful ? kActionCodeSuccess : kActionCodeDownloadTransferError; |
| 140 if (code == kActionCodeSuccess) { | 140 if (code == kActionCodeSuccess) { |
| 141 // Make sure hash is correct | 141 // Makes sure the hash and size are correct. |
| 142 omaha_hash_calculator_.Finalize(); | 142 omaha_hash_calculator_.Finalize(); |
| 143 if (omaha_hash_calculator_.hash() != install_plan_.download_hash) { | 143 if (omaha_hash_calculator_.hash() != install_plan_.download_hash) { |
| 144 LOG(ERROR) << "Download of " << install_plan_.download_url | 144 LOG(ERROR) << "Download of " << install_plan_.download_url |
| 145 << " failed. Expect hash " << install_plan_.download_hash | 145 << " failed. Expected hash " << install_plan_.download_hash |
| 146 << " but got hash " << omaha_hash_calculator_.hash(); | 146 << " but got hash " << omaha_hash_calculator_.hash(); |
| 147 code = kActionCodeDownloadHashMismatchError; | 147 code = kActionCodeDownloadHashMismatchError; |
| 148 } else if (bytes_received_ != install_plan_.size) { |
| 149 LOG(ERROR) << "Download of " << install_plan_.download_url |
| 150 << " failed. Expected size " << install_plan_.size |
| 151 << " but got size " << bytes_received_; |
| 152 code = kActionCodeDownloadSizeMismatchError; |
| 148 } | 153 } |
| 149 } | 154 } |
| 150 | 155 |
| 151 FlushLinuxCaches(); | 156 FlushLinuxCaches(); |
| 152 | 157 |
| 153 // Write the path to the output pipe if we're successful. | 158 // Write the path to the output pipe if we're successful. |
| 154 if (code == kActionCodeSuccess && HasOutputPipe()) | 159 if (code == kActionCodeSuccess && HasOutputPipe()) |
| 155 SetOutputObject(GetInputObject()); | 160 SetOutputObject(GetInputObject()); |
| 156 processor_->ActionComplete(this, code); | 161 processor_->ActionComplete(this, code); |
| 157 } | 162 } |
| 158 | 163 |
| 159 }; // namespace {} | 164 }; // namespace {} |
| OLD | NEW |