summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Alex Buynytskyy <alexbuy@google.com> 2022-03-29 21:09:00 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2022-03-29 21:09:00 +0000
commitfd918caf415b3cc6991ed23f9a04db7eafda23fa (patch)
tree5bb521ff0b44cf8543d9a46cfd450a35c1cbac72
parent56becd9a2e8abc5694809a7af6b69eeab018fb23 (diff)
parentdb0b76fa5ce31c3e69faaa71c87a083a2361bced (diff)
Merge "Retry the dir deletion if can't rename." am: d2ed995e83 am: d536f3007e am: db0b76fa5c
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2047963 Change-Id: Ic823f9fcdea409a35dd2a652b89f895249af85c4 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--cmds/installd/utils.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/cmds/installd/utils.cpp b/cmds/installd/utils.cpp
index 9801a9b3a4..45aeab6fa8 100644
--- a/cmds/installd/utils.cpp
+++ b/cmds/installd/utils.cpp
@@ -707,16 +707,16 @@ static int rename_delete_dir_contents(const std::string& pathname,
auto temp_dir_path =
base::StringPrintf("%s/%s", Dirname(pathname).c_str(), temp_dir_name.c_str());
- if (::rename(pathname.c_str(), temp_dir_path.c_str())) {
+ auto dir_to_delete = temp_dir_path.c_str();
+ if (::rename(pathname.c_str(), dir_to_delete)) {
if (ignore_if_missing && (errno == ENOENT)) {
return 0;
}
- ALOGE("Couldn't rename %s -> %s: %s \n", pathname.c_str(), temp_dir_path.c_str(),
- strerror(errno));
- return -errno;
+ ALOGE("Couldn't rename %s -> %s: %s \n", pathname.c_str(), dir_to_delete, strerror(errno));
+ dir_to_delete = pathname.c_str();
}
- return delete_dir_contents(temp_dir_path.c_str(), 1, exclusion_predicate, ignore_if_missing);
+ return delete_dir_contents(dir_to_delete, 1, exclusion_predicate, ignore_if_missing);
}
bool is_renamed_deleted_dir(const std::string& path) {