| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <glib.h> | 8 #include <glib.h> |
| 9 #include "update_engine/action_pipe.h" | 9 #include "update_engine/action_pipe.h" |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 http_fetcher_->set_delegate(this); | 24 http_fetcher_->set_delegate(this); |
| 25 CHECK(!writer_); | 25 CHECK(!writer_); |
| 26 direct_file_writer_.reset(new DirectFileWriter); | 26 direct_file_writer_.reset(new DirectFileWriter); |
| 27 | 27 |
| 28 // Get the InstallPlan and read it | 28 // Get the InstallPlan and read it |
| 29 CHECK(HasInputObject()); | 29 CHECK(HasInputObject()); |
| 30 InstallPlan install_plan(GetInputObject()); | 30 InstallPlan install_plan(GetInputObject()); |
| 31 | 31 |
| 32 should_decompress_ = install_plan.is_full_update; | 32 should_decompress_ = install_plan.is_full_update; |
| 33 url_ = install_plan.download_url; | 33 url_ = install_plan.download_url; |
| 34 output_path_ = install_plan.download_path; | 34 output_path_ = install_plan.install_path; |
| 35 hash_ = install_plan.download_hash; | 35 hash_ = install_plan.download_hash; |
| 36 install_plan.Dump(); | 36 install_plan.Dump(); |
| 37 | 37 |
| 38 if (should_decompress_) { | 38 if (should_decompress_) { |
| 39 decompressing_file_writer_.reset( | 39 decompressing_file_writer_.reset( |
| 40 new GzipDecompressingFileWriter(direct_file_writer_.get())); | 40 new GzipDecompressingFileWriter(direct_file_writer_.get())); |
| 41 writer_ = decompressing_file_writer_.get(); | 41 writer_ = decompressing_file_writer_.get(); |
| 42 output_path_ = install_plan.install_path; | |
| 43 } else { | 42 } else { |
| 44 writer_ = direct_file_writer_.get(); | 43 writer_ = direct_file_writer_.get(); |
| 45 } | 44 } |
| 46 int rc = writer_->Open(output_path_.c_str(), | 45 int rc = writer_->Open(output_path_.c_str(), |
| 47 O_TRUNC | O_WRONLY | O_CREAT | O_LARGEFILE, 0644); | 46 O_TRUNC | O_WRONLY | O_CREAT | O_LARGEFILE, 0644); |
| 48 if (rc < 0) { | 47 if (rc < 0) { |
| 49 LOG(ERROR) << "Unable to open output file " << output_path_; | 48 LOG(ERROR) << "Unable to open output file " << output_path_; |
| 50 // report error to processor | 49 // report error to processor |
| 51 processor_->ActionComplete(this, false); | 50 processor_->ActionComplete(this, false); |
| 52 return; | 51 return; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 } | 83 } |
| 85 } | 84 } |
| 86 | 85 |
| 87 // Write the path to the output pipe if we're successful | 86 // Write the path to the output pipe if we're successful |
| 88 if (successful && HasOutputPipe()) | 87 if (successful && HasOutputPipe()) |
| 89 SetOutputObject(GetInputObject()); | 88 SetOutputObject(GetInputObject()); |
| 90 processor_->ActionComplete(this, successful); | 89 processor_->ActionComplete(this, successful); |
| 91 } | 90 } |
| 92 | 91 |
| 93 }; // namespace {} | 92 }; // namespace {} |
| OLD | NEW |