diff options
author | Ng Zhi An <zhin@google.com> | 2019-01-23 13:52:48 -0800 |
---|---|---|
committer | Ng Zhi An <zhin@google.com> | 2019-01-23 15:16:29 -0800 |
commit | 14417a5d2ac04fc5d80c95d3aa31a27b1fc4a0b3 (patch) | |
tree | 1bfcc933fd0638982b5071793f038caab9982b32 | |
parent | 4475f7330aa6ca77f1ef7b0826ecf8edfd346035 (diff) | |
download | android_bootable_recovery-14417a5d2ac04fc5d80c95d3aa31a27b1fc4a0b3.tar.gz android_bootable_recovery-14417a5d2ac04fc5d80c95d3aa31a27b1fc4a0b3.tar.bz2 android_bootable_recovery-14417a5d2ac04fc5d80c95d3aa31a27b1fc4a0b3.zip |
Check that install file exists before unlink
This will remove spurious error messages in logcat such as:
08-02 00:27:21.580 600 600 E /system/bin/recovery-persist: Failed to
unlink /data/misc/recovery/last_install: No such file or directory
since the install file doesn't exist in the first place.
Bug: None
Test: m
Change-Id: Ifaa95729c50efae4e641286dfbe1718aceb5f50a
-rw-r--r-- | recovery-persist.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/recovery-persist.cpp b/recovery-persist.cpp index ebb42d22..e2a6699f 100644 --- a/recovery-persist.cpp +++ b/recovery-persist.cpp @@ -158,7 +158,7 @@ int main(int argc, char **argv) { // 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 @@ int main(int argc, char **argv) { // /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; } } |