Merge "Remove pre-N db after successful migration" into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
cdb5fcf7b8
@@ -4696,26 +4696,20 @@ public class AccountManagerService
|
|||||||
ceHelper.getWritableDatabase();
|
ceHelper.getWritableDatabase();
|
||||||
ceHelper.close();
|
ceHelper.close();
|
||||||
if (removeOldDb) {
|
if (removeOldDb) {
|
||||||
// TODO STOPSHIP - backup file during testing. Remove file before the release
|
Slog.i(TAG, "Migration complete - removing pre-N db " + preNDatabaseFile);
|
||||||
Log.i(TAG, "Migration complete - creating backup of old db " + preNDatabaseFile);
|
if (!SQLiteDatabase.deleteDatabase(preNDatabaseFile)) {
|
||||||
renameToBakFile(preNDatabaseFile);
|
Slog.e(TAG, "Cannot remove pre-N db " + preNDatabaseFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ceHelper;
|
return ceHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void renameToBakFile(File file) {
|
|
||||||
File bakFile = new File(file.getPath() + ".bak");
|
|
||||||
if (!file.renameTo(bakFile)) {
|
|
||||||
Log.e(TAG, "Cannot move file to " + bakFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean migratePreNDbToCe(File oldDbFile, File ceDbFile) {
|
private static boolean migratePreNDbToCe(File oldDbFile, File ceDbFile) {
|
||||||
Log.i(TAG, "Moving pre-N DB " + oldDbFile + " to CE " + ceDbFile);
|
Slog.i(TAG, "Moving pre-N DB " + oldDbFile + " to CE " + ceDbFile);
|
||||||
try {
|
try {
|
||||||
FileUtils.copyFileOrThrow(oldDbFile, ceDbFile);
|
FileUtils.copyFileOrThrow(oldDbFile, ceDbFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, "Cannot copy file to " + ceDbFile + " from " + oldDbFile, e);
|
Slog.e(TAG, "Cannot copy file to " + ceDbFile + " from " + oldDbFile, e);
|
||||||
// Try to remove potentially damaged file if I/O error occurred
|
// Try to remove potentially damaged file if I/O error occurred
|
||||||
deleteDbFileWarnIfFailed(ceDbFile);
|
deleteDbFileWarnIfFailed(ceDbFile);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user