Prevent restoring newer backups into older versions of Signal.

Relates to #8184
This commit is contained in:
Greyson Parrelli
2018-09-07 15:54:38 -07:00
parent d2a8abe769
commit 15b4517e35
3 changed files with 33 additions and 10 deletions

View File

@@ -98,7 +98,11 @@ public class FullBackupImporter extends FullBackupBase {
EventBus.getDefault().post(new BackupEvent(BackupEvent.Type.FINISHED, count));
}
private static void processVersion(@NonNull SQLiteDatabase db, DatabaseVersion version) {
private static void processVersion(@NonNull SQLiteDatabase db, DatabaseVersion version) throws IOException {
if (version.getVersion() > db.getVersion()) {
throw new DatabaseDowngradeException(db.getVersion(), version.getVersion());
}
db.setVersion(version.getVersion());
}
@@ -328,4 +332,9 @@ public class FullBackupImporter extends FullBackupBase {
}
}
public static class DatabaseDowngradeException extends IOException {
DatabaseDowngradeException(int currentVersion, int backupVersion) {
super("Tried to import a backup with version " + backupVersion + " into a database with version " + currentVersion);
}
}
}