File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
core/java/android/accounts Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -1817,7 +1817,16 @@ private static String getDatabaseName(int userId) {
18171817 // Migrate old file, if it exists, to the new location
18181818 File oldFile = new File (systemDir , DATABASE_NAME );
18191819 if (oldFile .exists ()) {
1820- oldFile .renameTo (databaseFile );
1820+ // Check for use directory; create if it doesn't exist, else renameTo will fail
1821+ File userDir = new File (systemDir , "users/" + userId );
1822+ if (!userDir .exists ()) {
1823+ if (!userDir .mkdirs ()) {
1824+ throw new IllegalStateException ("User dir cannot be created: " + userDir );
1825+ }
1826+ }
1827+ if (!oldFile .renameTo (databaseFile )) {
1828+ throw new IllegalStateException ("User dir cannot be migrated: " + databaseFile );
1829+ }
18211830 }
18221831 }
18231832 return databaseFile .getPath ();
You can’t perform that action at this time.
0 commit comments