cryptohome: UnmountAll if crypto migration fails.
UnmountAll is currently called only when the dircrypto migration
succeeds. For consistency it should also be called if the migration
fails.
BUG=chromium:713556
TEST=cros_workon_make --board=samus --test cryptohome
Change-Id: I65c49f3e5abc727160b086ea5db19957318eda63
Reviewed-on: https://chromium-review.googlesource.com/484179
Commit-Ready: Dan Spaid <dspaid@chromium.org>
Tested-by: Dan Spaid <dspaid@chromium.org>
Reviewed-by: Ryo Hashimoto <hashimoto@chromium.org>
diff --git a/cryptohome/mount.cc b/cryptohome/mount.cc
index b32748d..72f4883 100644
--- a/cryptohome/mount.cc
+++ b/cryptohome/mount.cc
@@ -1942,12 +1942,13 @@
constexpr uint64_t kMaxChunkSize = 128 * 1024 * 1024;
dircrypto_data_migrator::MigrationHelper migrator(
platform_, GetUserDirectoryForUser(obfuscated_username), kMaxChunkSize);
- if (!migrator.Migrate(temporary_mount, mount_point_, callback)) {
+ bool success = migrator.Migrate(temporary_mount, mount_point_, callback);
+ UnmountAll();
+ if (!success) {
LOG(ERROR) << "Failed to migrate.";
return false;
}
// Clean up.
- UnmountAll();
FilePath vault_path = GetUserVaultPath(obfuscated_username);
if (!platform_->DeleteFile(temporary_mount, true /* recursive */) ||
!platform_->DeleteFile(vault_path, true /* recursive */)) {