summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Alex Buynytskyy <alexbuy@google.com> 2022-03-29 09:15:04 -0700
committer Alex Buynytskyy <alexbuy@google.com> 2022-03-29 09:17:22 -0700
commitc6933673e80f6eb9f3cae19ce9c56f4ebaa72f54 (patch)
tree355a2bc7d3aa6ec5b12fd6434785b6538efafd61
parent171a64a823952b0ab210688a1d342e9882078400 (diff)
Retry the dir deletion if can't rename.
Previously we would give up. Bug: 226580398 Fixes: 226580398 Test: atest installd_service_test installd_cache_test installd_utils_test installd_dexopt_test installd_otapreopt_test installd_file_test Change-Id: I791116f52397b24747bc7cbb1f94c696d0b832c1
-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 2ed971da0e..c7bea3f4a9 100644
--- a/cmds/installd/utils.cpp
+++ b/cmds/installd/utils.cpp
@@ -705,16 +705,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) {