Skip to content

Commit 856fbbe

Browse files
Amith YamasaniAndroid (Google) Code Review
authored andcommitted
Merge "Don't migrate accounts.db if already migrated."
2 parents c267610 + a23bb38 commit 856fbbe

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

core/java/android/accounts/AccountManagerService.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1869,9 +1869,12 @@ private static String getDatabaseName(int userId) {
18691869
File systemDir = Environment.getSystemSecureDirectory();
18701870
File databaseFile = new File(systemDir, "users/" + userId + "/" + DATABASE_NAME);
18711871
if (userId == 0) {
1872-
// Migrate old file, if it exists, to the new location
1872+
// Migrate old file, if it exists, to the new location.
1873+
// Make sure the new file doesn't already exist. A dummy file could have been
1874+
// accidentally created in the old location, causing the new one to become corrupted
1875+
// as well.
18731876
File oldFile = new File(systemDir, DATABASE_NAME);
1874-
if (oldFile.exists()) {
1877+
if (oldFile.exists() && !databaseFile.exists()) {
18751878
// Check for use directory; create if it doesn't exist, else renameTo will fail
18761879
File userDir = new File(systemDir, "users/" + userId);
18771880
if (!userDir.exists()) {

0 commit comments

Comments
 (0)