diff options
author | Mathieu Chartier <mathieuc@google.com> | 2016-01-28 12:02:00 -0800 |
---|---|---|
committer | Mathieu Chartier <mathieuc@google.com> | 2016-01-28 12:02:00 -0800 |
commit | 784bb0915499d38c9bdca91bf6335fe0d503bc51 (patch) | |
tree | 3ce350f0acde531589d4c7af77452a04d32ca4d9 /compiler/image_writer.cc | |
parent | 1c7736c2823b1127e0e19fa4d71795b894632bc0 (diff) | |
download | android_art-784bb0915499d38c9bdca91bf6335fe0d503bc51.tar.gz android_art-784bb0915499d38c9bdca91bf6335fe0d503bc51.tar.bz2 android_art-784bb0915499d38c9bdca91bf6335fe0d503bc51.zip |
Clear image file in image writer
The goal is to not erase the image file in installd in case we abort
compilation due to no new profile data. Currently aborting results in
an empty image file.
Bug: 22858531
Change-Id: I32eee3391f860f4a373db3d746d096cc36d623f2
Diffstat (limited to 'compiler/image_writer.cc')
-rw-r--r-- | compiler/image_writer.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc index c8720eab8a..6abc6fae8a 100644 --- a/compiler/image_writer.cc +++ b/compiler/image_writer.cc @@ -276,6 +276,11 @@ bool ImageWriter::Write(int image_fd, if (image_fd != kInvalidFd) { if (strlen(image_filename) == 0u) { image_file.reset(new File(image_fd, unix_file::kCheckSafeUsage)); + // Empty the file in case it already exists. + if (image_file != nullptr) { + TEMP_FAILURE_RETRY(image_file->SetLength(0)); + TEMP_FAILURE_RETRY(image_file->Flush()); + } } else { LOG(ERROR) << "image fd " << image_fd << " name " << image_filename; } |