diff options
| author | 2016-03-22 10:06:33 +0600 | |
|---|---|---|
| committer | 2016-03-31 10:17:18 +0600 | |
| commit | d12f9c13599a6b5893cffd02c9b8d35b4db93bf3 (patch) | |
| tree | 342ff38f30c85e0ac997fe3eb8401c3e3e0ee8db | |
| parent | 20eef176101924d5047895214bad4e73b8ae35ec (diff) | |
ART: Save or erase the file even if I/O failed
It should close the file in any case.
Change-Id: Idb7db15bfecb0ac47839be3544cc2dce91096d7b
Signed-off-by: Serdjuk, Nikolay Y <nikolay.y.serdjuk@intel.com>
| -rw-r--r-- | patchoat/patchoat.cc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/patchoat/patchoat.cc b/patchoat/patchoat.cc index 63ae342e1f..a1b3c9e12e 100644 --- a/patchoat/patchoat.cc +++ b/patchoat/patchoat.cc @@ -320,11 +320,11 @@ bool PatchOat::Patch(const std::string& image_location, PatchOat& p = space_to_patchoat_map.find(space)->second; - if (!p.WriteImage(output_image_file.get())) { - LOG(ERROR) << "Failed to write image file " << output_image_file->GetPath(); + bool success = p.WriteImage(output_image_file.get()); + success = FinishFile(output_image_file.get(), success); + if (!success) { return false; } - FinishFile(output_image_file.get(), true); bool skip_patching_oat = space_to_skip_patching_map.find(space)->second; if (!skip_patching_oat) { @@ -336,11 +336,11 @@ bool PatchOat::Patch(const std::string& image_location, LOG(ERROR) << "Failed to open output oat file at " << output_oat_filename; return false; } - if (!p.WriteElf(output_oat_file.get())) { - LOG(ERROR) << "Failed to write oat file " << output_oat_file->GetPath(); + success = p.WriteElf(output_oat_file.get()); + success = FinishFile(output_oat_file.get(), success); + if (!success) { return false; } - FinishFile(output_oat_file.get(), true); } } return true; |