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

Side by Side Diff: download_action.cc

Issue 3046007: Add and emit download action error codes. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: Created 10 years, 5 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 delta_performer_.reset(new DeltaPerformer); 54 delta_performer_.reset(new DeltaPerformer);
55 writer_ = delta_performer_.get(); 55 writer_ = delta_performer_.get();
56 } 56 }
57 } 57 }
58 int rc = writer_->Open(install_plan_.install_path.c_str(), 58 int rc = writer_->Open(install_plan_.install_path.c_str(),
59 O_TRUNC | O_WRONLY | O_CREAT | O_LARGEFILE, 59 O_TRUNC | O_WRONLY | O_CREAT | O_LARGEFILE,
60 0644); 60 0644);
61 if (rc < 0) { 61 if (rc < 0) {
62 LOG(ERROR) << "Unable to open output file " << install_plan_.install_path; 62 LOG(ERROR) << "Unable to open output file " << install_plan_.install_path;
63 // report error to processor 63 // report error to processor
64 processor_->ActionComplete(this, kActionCodeError); 64 processor_->ActionComplete(this, kActionCodeInstallDeviceOpenError);
65 return; 65 return;
66 } 66 }
67 if (!install_plan_.is_full_update) { 67 if (!install_plan_.is_full_update) {
68 if (!delta_performer_->OpenKernel( 68 if (!delta_performer_->OpenKernel(
69 install_plan_.kernel_install_path.c_str())) { 69 install_plan_.kernel_install_path.c_str())) {
70 LOG(ERROR) << "Unable to open kernel file " 70 LOG(ERROR) << "Unable to open kernel file "
71 << install_plan_.kernel_install_path.c_str(); 71 << install_plan_.kernel_install_path.c_str();
72 writer_->Close(); 72 writer_->Close();
73 processor_->ActionComplete(this, kActionCodeError); 73 processor_->ActionComplete(this, kActionCodeKernelDeviceOpenError);
74 return; 74 return;
75 } 75 }
76 } 76 }
77 http_fetcher_->BeginTransfer(install_plan_.download_url); 77 http_fetcher_->BeginTransfer(install_plan_.download_url);
78 } 78 }
79 79
80 void DownloadAction::TerminateProcessing() { 80 void DownloadAction::TerminateProcessing() {
81 CHECK(writer_); 81 CHECK(writer_);
82 CHECK_EQ(writer_->Close(), 0); 82 CHECK_EQ(writer_->Close(), 0);
83 writer_ = NULL; 83 writer_ = NULL;
(...skipping 25 matching lines...) Expand all
109 109
110 LOG(INFO) << "FlushLinuxCaches done."; 110 LOG(INFO) << "FlushLinuxCaches done.";
111 } 111 }
112 } 112 }
113 113
114 void DownloadAction::TransferComplete(HttpFetcher *fetcher, bool successful) { 114 void DownloadAction::TransferComplete(HttpFetcher *fetcher, bool successful) {
115 if (writer_) { 115 if (writer_) {
116 CHECK_EQ(writer_->Close(), 0) << errno; 116 CHECK_EQ(writer_->Close(), 0) << errno;
117 writer_ = NULL; 117 writer_ = NULL;
118 } 118 }
119 if (successful) { 119 ActionExitCode code =
120 successful ? kActionCodeSuccess : kActionCodeDownloadTransferError;
121 if (code == kActionCodeSuccess) {
120 // Make sure hash is correct 122 // Make sure hash is correct
121 omaha_hash_calculator_.Finalize(); 123 omaha_hash_calculator_.Finalize();
122 if (omaha_hash_calculator_.hash() != install_plan_.download_hash) { 124 if (omaha_hash_calculator_.hash() != install_plan_.download_hash) {
123 LOG(ERROR) << "Download of " << install_plan_.download_url 125 LOG(ERROR) << "Download of " << install_plan_.download_url
124 << " failed. Expect hash " << install_plan_.download_hash 126 << " failed. Expect hash " << install_plan_.download_hash
125 << " but got hash " << omaha_hash_calculator_.hash(); 127 << " but got hash " << omaha_hash_calculator_.hash();
126 successful = false; 128 code = kActionCodeDownloadHashMismatchError;
127 } 129 }
128 } 130 }
129 131
130 FlushLinuxCaches(); 132 FlushLinuxCaches();
131 133
132 // Write the path to the output pipe if we're successful 134 // Write the path to the output pipe if we're successful.
133 if (successful && HasOutputPipe()) 135 if (code == kActionCodeSuccess && HasOutputPipe())
134 SetOutputObject(GetInputObject()); 136 SetOutputObject(GetInputObject());
135 processor_->ActionComplete( 137 processor_->ActionComplete(this, code);
136 this,
137 successful ? kActionCodeSuccess : kActionCodeError);
138 } 138 }
139 139
140 }; // namespace {} 140 }; // 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