Snap for 5262136 from 794b9818239abc41e19ee81fca9f1fb305c46acc to qt-release
Change-Id: Ibb0478a68322fa4461812da6b918804bf1c0f263
diff --git a/recovery-persist.cpp b/recovery-persist.cpp
index ebb42d2..e2a6699 100644
--- a/recovery-persist.cpp
+++ b/recovery-persist.cpp
@@ -158,7 +158,7 @@
// Collects and reports the non-a/b update metrics from last_install; and removes the file
// to avoid duplicate report.
report_metrics_from_last_install(LAST_INSTALL_FILE_IN_CACHE);
- if (unlink(LAST_INSTALL_FILE_IN_CACHE) == -1) {
+ if (access(LAST_INSTALL_FILE_IN_CACHE, F_OK) && unlink(LAST_INSTALL_FILE_IN_CACHE) == -1) {
PLOG(ERROR) << "Failed to unlink " << LAST_INSTALL_FILE_IN_CACHE;
}
@@ -182,7 +182,7 @@
// /data/misc/recovery from pmsg. Looks for the sideload history only.
if (!has_cache) {
report_metrics_from_last_install(LAST_INSTALL_FILE);
- if (unlink(LAST_INSTALL_FILE) == -1) {
+ if (access(LAST_INSTALL_FILE, F_OK) && unlink(LAST_INSTALL_FILE) == -1) {
PLOG(ERROR) << "Failed to unlink " << LAST_INSTALL_FILE;
}
}