cryptohome: Delete old mountpoints in HomeDirs::Rename()

These directories are empty and will be re-created when mounting.

BUG=chromium:1072253
TEST=Rename a user's home to a different name, rename it back, and
succeeds to log in.

Change-Id: I41ceb31bbf8f311edcf9850e0ba35e8650d55b4b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2156665
Tested-by: Ryo Hashimoto <hashimoto@chromium.org>
Reviewed-by: Jorge Lucangeli Obes <jorgelo@chromium.org>
Commit-Queue: Ryo Hashimoto <hashimoto@chromium.org>
(cherry picked from commit d90aa65882ddeb44cb800a93152f69041e606272)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2174115
Reviewed-by: Ryo Hashimoto <hashimoto@chromium.org>
diff --git a/cryptohome/homedirs.cc b/cryptohome/homedirs.cc
index a0d218d..0151cf5 100644
--- a/cryptohome/homedirs.cc
+++ b/cryptohome/homedirs.cc
@@ -1508,33 +1508,31 @@
     return false;
   }
 
-  // |user_dir_renamed| is return value, because two other directories are
+  // |user_dir_renamed| is return value, because three other directories are
   // empty and will be created as needed.
   const bool user_dir_renamed =
       !base::PathExists(user_dir_from) ||
       platform_->Rename(user_dir_from, user_dir_to);
 
   if (user_dir_renamed) {
-    const bool user_path_renamed =
-        !base::PathExists(user_path_from) ||
-        platform_->Rename(user_path_from, user_path_to);
-    const bool root_path_renamed =
-        !base::PathExists(root_path_from) ||
-        platform_->Rename(root_path_from, root_path_to);
-    const bool new_user_path_renamed =
-        !base::PathExists(new_user_path_from) ||
-        platform_->Rename(new_user_path_from, new_user_path_to);
-    if (!user_path_renamed) {
+    constexpr bool kIsRecursive = true;
+    const bool user_path_deleted =
+        platform_->DeleteFile(user_path_from, kIsRecursive);
+    const bool root_path_deleted =
+        platform_->DeleteFile(root_path_from, kIsRecursive);
+    const bool new_user_path_deleted =
+        platform_->DeleteFile(new_user_path_from, kIsRecursive);
+    if (!user_path_deleted) {
       LOG(WARNING) << "HomeDirs::Rename(from='" << account_id_from << "', to='"
-                   << account_id_to << "'): failed to rename user_path.";
+                   << account_id_to << "'): failed to delete user_path.";
     }
-    if (!root_path_renamed) {
+    if (!root_path_deleted) {
       LOG(WARNING) << "HomeDirs::Rename(from='" << account_id_from << "', to='"
-                   << account_id_to << "'): failed to rename root_path.";
+                   << account_id_to << "'): failed to delete root_path.";
     }
-    if (!new_user_path_renamed) {
+    if (!new_user_path_deleted) {
       LOG(WARNING) << "HomeDirs::Rename(from='" << account_id_from << "', to='"
-                   << account_id_to << "'): failed to rename new_user_path.";
+                   << account_id_to << "'): failed to delete new_user_path.";
     }
   } else {
     LOG(ERROR) << "HomeDirs::Rename(from='" << account_id_from << "', to='"