OLD | NEW |
1 // Copyright (c) 2009 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> |
11 #include "update_engine/action_pipe.h" | 11 #include "update_engine/action_pipe.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, false); | 64 processor_->ActionComplete(this, kActionCodeError); |
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, false); | 73 processor_->ActionComplete(this, kActionCodeError); |
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 if (successful) { | 119 if (successful) { |
120 // Make sure hash is correct | 120 // Make sure hash is correct |
121 omaha_hash_calculator_.Finalize(); | 121 omaha_hash_calculator_.Finalize(); |
122 if (omaha_hash_calculator_.hash() != install_plan_.download_hash) { | 122 if (omaha_hash_calculator_.hash() != install_plan_.download_hash) { |
123 LOG(ERROR) << "Download of " << install_plan_.download_url | 123 LOG(ERROR) << "Download of " << install_plan_.download_url |
124 << " failed. Expect hash " << install_plan_.download_hash | 124 << " failed. Expect hash " << install_plan_.download_hash |
125 << " but got hash " << omaha_hash_calculator_.hash(); | 125 << " but got hash " << omaha_hash_calculator_.hash(); |
126 successful = false; | 126 successful = false; |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 FlushLinuxCaches(); | 130 FlushLinuxCaches(); |
131 | 131 |
132 // Write the path to the output pipe if we're successful | 132 // Write the path to the output pipe if we're successful |
133 if (successful && HasOutputPipe()) | 133 if (successful && HasOutputPipe()) |
134 SetOutputObject(GetInputObject()); | 134 SetOutputObject(GetInputObject()); |
135 processor_->ActionComplete(this, successful); | 135 processor_->ActionComplete( |
| 136 this, |
| 137 successful ? kActionCodeSuccess : kActionCodeError); |
136 } | 138 } |
137 | 139 |
138 }; // namespace {} | 140 }; // namespace {} |
OLD | NEW |