Fix SQL crash in backup restore by preventing job from running until restore complete.

This commit is contained in:
Cody Henthorne
2023-06-14 10:28:34 -04:00
committed by GitHub
parent 9c0c25ef99
commit 305edf1928
6 changed files with 78 additions and 1 deletions

View File

@@ -17,6 +17,7 @@ import org.thoughtcrime.securesms.backup.BackupPassphrase;
import org.thoughtcrime.securesms.backup.FullBackupImporter;
import org.thoughtcrime.securesms.crypto.AttachmentSecretProvider;
import org.thoughtcrime.securesms.database.SignalDatabase;
import org.thoughtcrime.securesms.jobmanager.impl.DataRestoreConstraint;
import org.thoughtcrime.securesms.notifications.NotificationChannels;
import java.io.IOException;
@@ -38,6 +39,7 @@ final class NewDeviceServerTask implements ServerTask {
EventBus.getDefault().register(this);
try {
DataRestoreConstraint.setRestoringData(true);
SQLiteDatabase database = SignalDatabase.getBackupDatabase();
String passphrase = "deadbeef";
@@ -66,6 +68,7 @@ final class NewDeviceServerTask implements ServerTask {
EventBus.getDefault().post(new Status(0, Status.State.FAILURE_UNKNOWN));
} finally {
EventBus.getDefault().unregister(this);
DataRestoreConstraint.setRestoringData(false);
}
long end = System.currentTimeMillis();