Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b106153b authored by Marc Blank's avatar Marc Blank Committed by Android (Google) Code Review
Browse files

Merge "Use renameTo safely when creating the user 0 account database"

parents bf02b984 c6b0f99b
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -1817,7 +1817,16 @@ public class AccountManagerService
            // Migrate old file, if it exists, to the new location
            File oldFile = new File(systemDir, DATABASE_NAME);
            if (oldFile.exists()) {
                oldFile.renameTo(databaseFile);
                // Check for use directory; create if it doesn't exist, else renameTo will fail
                File userDir = new File(systemDir, "users/" + userId);
                if (!userDir.exists()) {
                    if (!userDir.mkdirs()) {
                        throw new IllegalStateException("User dir cannot be created: " + userDir);
                    }
                }
                if (!oldFile.renameTo(databaseFile)) {
                    throw new IllegalStateException("User dir cannot be migrated: " + databaseFile);
                }
            }
        }
        return databaseFile.getPath();