Fix crash during cache warming for fresh installs.

fork-5.53.8
Greyson Parrelli 2021-07-19 13:01:53 -04:00
rodzic b9514d0b94
commit 556518973d
1 zmienionych plików z 15 dodań i 11 usunięć

Wyświetl plik

@ -16,6 +16,7 @@ import org.thoughtcrime.securesms.database.RecipientDatabase;
import org.thoughtcrime.securesms.database.RecipientDatabase.MissingRecipientException;
import org.thoughtcrime.securesms.database.ThreadDatabase;
import org.thoughtcrime.securesms.database.model.ThreadRecord;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.util.CursorUtil;
import org.thoughtcrime.securesms.util.LRUCache;
import org.thoughtcrime.securesms.util.Stopwatch;
@ -198,6 +199,7 @@ public final class LiveRecipientCache {
stopwatch.split("thread");
if (SignalStore.registrationValues().isRegistrationComplete()) {
try (Cursor cursor = DatabaseFactory.getRecipientDatabase(context).getNonGroupContacts(false)) {
int count = 0;
while (cursor != null && cursor.moveToNext() && count < CONTACT_CACHE_WARM_MAX) {
@ -209,8 +211,10 @@ public final class LiveRecipientCache {
Log.d(TAG, "Warmed up " + count + " contact recipient.");
stopwatch.split("contact");
stopwatch.stop(TAG);
}
}
stopwatch.stop(TAG);
});
}