Decrypt and process messages all in one transaction.

Giddy up
This commit is contained in:
Greyson Parrelli
2021-02-23 18:34:18 -05:00
committed by GitHub
parent d651716d99
commit 8950100bd7
21 changed files with 2523 additions and 2008 deletions

View File

@@ -34,6 +34,7 @@ import org.thoughtcrime.securesms.transport.RetryLaterException;
import org.thoughtcrime.securesms.util.FileUtils;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.VersionTracker;
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
import java.io.File;
import java.util.List;
@@ -290,10 +291,10 @@ public class LegacyMigrationJob extends MigrationJob {
PushDatabase pushDatabase = DatabaseFactory.getPushDatabase(context);
JobManager jobManager = ApplicationDependencies.getJobManager();
try (Cursor pushReader = pushDatabase.getPending()) {
while (pushReader != null && pushReader.moveToNext()) {
jobManager.add(new PushDecryptMessageJob(context,
pushReader.getLong(pushReader.getColumnIndexOrThrow(PushDatabase.ID))));
try (PushDatabase.Reader pushReader = pushDatabase.readerFor(pushDatabase.getPending())) {
SignalServiceEnvelope envelope;
while ((envelope = pushReader.getNext()) != null) {
jobManager.add(new PushDecryptMessageJob(context, envelope));
}
}
}