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

Side by Side Diff: download_action.cc

Issue 3499004: AU: Verify that the actual download size matches the size reported by Omaha. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: extra ; Created 10 years, 2 months 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 | « action_processor.h ('k') | download_action_unittest.cc » ('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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 {}
OLDNEW
« no previous file with comments | « action_processor.h ('k') | download_action_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698