File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
core/java/android/accounts Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff 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 ()) {
You can’t perform that action at this time.
0 commit comments