mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 14:48:35 +00:00
Fix storage service crash with new users.
This commit is contained in:
parent
d507be0ab0
commit
9c96afee09
@ -456,9 +456,22 @@ public class RecipientDatabase extends Database {
|
||||
db.beginTransaction();
|
||||
|
||||
try {
|
||||
|
||||
for (SignalContactRecord insert : contactInserts) {
|
||||
ContentValues values = getValuesForStorageContact(insert);
|
||||
long id = db.insertOrThrow(TABLE_NAME, null, values);
|
||||
long id = db.insertWithOnConflict(TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_IGNORE);
|
||||
|
||||
if (id < 0) {
|
||||
Log.w(TAG, "Failed to insert! It's likely that these were newly-registered users that were missed in the merge. Doing an update instead.");
|
||||
|
||||
if (insert.getAddress().getNumber().isPresent()) {
|
||||
int count = db.update(TABLE_NAME, values, PHONE + " = ?", new String[] { insert.getAddress().getNumber().get() });
|
||||
Log.w(TAG, "Updated " + count + " users by E164.");
|
||||
} else {
|
||||
int count = db.update(TABLE_NAME, values, UUID + " = ?", new String[] { insert.getAddress().getUuid().get().toString() });
|
||||
Log.w(TAG, "Updated " + count + " users by UUID.");
|
||||
}
|
||||
} else {
|
||||
RecipientId recipientId = RecipientId.from(id);
|
||||
|
||||
if (insert.getIdentityKey().isPresent()) {
|
||||
@ -476,6 +489,7 @@ public class RecipientDatabase extends Database {
|
||||
TextSecurePreferences.setProfileName(context, ProfileName.fromParts(insert.getGivenName().orNull(), insert.getFamilyName().orNull()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (StorageSyncHelper.ContactUpdate update : contactUpdates) {
|
||||
ContentValues values = getValuesForStorageContact(update.getNew());
|
||||
|
Loading…
x
Reference in New Issue
Block a user