Fix ApplicationMigrations UI.

This commit is contained in:
Greyson Parrelli
2021-07-15 13:19:06 -04:00
parent 83086a5a2b
commit b04ca202f6
8 changed files with 59 additions and 58 deletions

View File

@@ -227,8 +227,6 @@ public class DatabaseFactory {
}
private DatabaseFactory(@NonNull Context context) {
SQLiteDatabase.loadLibs(context);
DatabaseSecret databaseSecret = DatabaseSecretProvider.getOrCreateDatabaseSecret(context);
AttachmentSecret attachmentSecret = AttachmentSecretProvider.getInstance(context).getOrCreateAttachmentSecret();

View File

@@ -11,6 +11,7 @@ import com.annimon.stream.Stream;
import net.sqlcipher.database.SQLiteOpenHelper;
import net.sqlcipher.database.SQLiteDatabase;
import org.signal.core.util.concurrent.SignalExecutors;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.crypto.DatabaseSecret;
import org.thoughtcrime.securesms.crypto.DatabaseSecretProvider;
@@ -140,9 +141,11 @@ public class JobDatabase extends SQLiteOpenHelper implements SignalDatabase {
public void onOpen(SQLiteDatabase db) {
Log.i(TAG, "onOpen()");
dropTableIfPresent("job_spec");
dropTableIfPresent("constraint_spec");
dropTableIfPresent("dependency_spec");
SignalExecutors.BOUNDED.execute(() -> {
dropTableIfPresent("job_spec");
dropTableIfPresent("constraint_spec");
dropTableIfPresent("dependency_spec");
});
}
public synchronized void insertJobs(@NonNull List<FullSpec> fullSpecs) {

View File

@@ -10,6 +10,7 @@ import net.sqlcipher.database.SQLiteDatabase;
import net.sqlcipher.database.SQLiteDatabaseHook;
import net.sqlcipher.database.SQLiteOpenHelper;
import org.signal.core.util.concurrent.SignalExecutors;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.crypto.DatabaseSecret;
import org.thoughtcrime.securesms.crypto.DatabaseSecretProvider;
@@ -88,10 +89,12 @@ public class KeyValueDatabase extends SQLiteOpenHelper implements SignalDatabase
public void onOpen(SQLiteDatabase db) {
Log.i(TAG, "onOpen()");
if (DatabaseFactory.getInstance(application).hasTable("key_value")) {
Log.i(TAG, "Dropping original key_value table from the main database.");
DatabaseFactory.getInstance(application).getRawDatabase().rawExecSQL("DROP TABLE key_value");
}
SignalExecutors.BOUNDED.execute(() -> {
if (DatabaseFactory.getInstance(application).hasTable("key_value")) {
Log.i(TAG, "Dropping original key_value table from the main database.");
DatabaseFactory.getInstance(application).getRawDatabase().rawExecSQL("DROP TABLE key_value");
}
});
}
public @NonNull KeyValueDataSet getDataSet() {

View File

@@ -9,6 +9,7 @@ import androidx.annotation.NonNull;
import net.sqlcipher.database.SQLiteDatabase;
import net.sqlcipher.database.SQLiteOpenHelper;
import org.signal.core.util.concurrent.SignalExecutors;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.crypto.DatabaseSecret;
import org.thoughtcrime.securesms.crypto.DatabaseSecretProvider;
@@ -91,10 +92,12 @@ public class MegaphoneDatabase extends SQLiteOpenHelper implements SignalDatabas
public void onOpen(SQLiteDatabase db) {
Log.i(TAG, "onOpen()");
if (DatabaseFactory.getInstance(application).hasTable("megaphone")) {
Log.i(TAG, "Dropping original megaphone table from the main database.");
DatabaseFactory.getInstance(application).getRawDatabase().rawExecSQL("DROP TABLE megaphone");
}
SignalExecutors.BOUNDED.execute(() -> {
if (DatabaseFactory.getInstance(application).hasTable("megaphone")) {
Log.i(TAG, "Dropping original megaphone table from the main database.");
DatabaseFactory.getInstance(application).getRawDatabase().rawExecSQL("DROP TABLE megaphone");
}
});
}
public void insert(@NonNull Collection<Event> events) {