mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 17:48:33 +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();
|
db.beginTransaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
for (SignalContactRecord insert : contactInserts) {
|
for (SignalContactRecord insert : contactInserts) {
|
||||||
ContentValues values = getValuesForStorageContact(insert);
|
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);
|
RecipientId recipientId = RecipientId.from(id);
|
||||||
|
|
||||||
if (insert.getIdentityKey().isPresent()) {
|
if (insert.getIdentityKey().isPresent()) {
|
||||||
@ -476,6 +489,7 @@ public class RecipientDatabase extends Database {
|
|||||||
TextSecurePreferences.setProfileName(context, ProfileName.fromParts(insert.getGivenName().orNull(), insert.getFamilyName().orNull()));
|
TextSecurePreferences.setProfileName(context, ProfileName.fromParts(insert.getGivenName().orNull(), insert.getFamilyName().orNull()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (StorageSyncHelper.ContactUpdate update : contactUpdates) {
|
for (StorageSyncHelper.ContactUpdate update : contactUpdates) {
|
||||||
ContentValues values = getValuesForStorageContact(update.getNew());
|
ContentValues values = getValuesForStorageContact(update.getNew());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user