kopia lustrzana https://github.com/ryukoposting/Signal-Android
Prevent crashing on duplicate gv1 storage records.
rodzic
faa19acf81
commit
0172c1e385
|
@ -812,7 +812,7 @@ public class RecipientDatabase extends Database {
|
|||
}
|
||||
}
|
||||
|
||||
public void applyStorageSyncUpdates(@NonNull Collection<SignalContactRecord> contactInserts,
|
||||
public boolean applyStorageSyncUpdates(@NonNull Collection<SignalContactRecord> contactInserts,
|
||||
@NonNull Collection<RecordUpdate<SignalContactRecord>> contactUpdates,
|
||||
@NonNull Collection<SignalGroupV1Record> groupV1Inserts,
|
||||
@NonNull Collection<RecordUpdate<SignalGroupV1Record>> groupV1Updates,
|
||||
|
@ -823,6 +823,7 @@ public class RecipientDatabase extends Database {
|
|||
IdentityDatabase identityDatabase = DatabaseFactory.getIdentityDatabase(context);
|
||||
ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(context);
|
||||
Set<RecipientId> needsRefresh = new HashSet<>();
|
||||
boolean forcePush = false;
|
||||
|
||||
db.beginTransaction();
|
||||
|
||||
|
@ -944,13 +945,18 @@ public class RecipientDatabase extends Database {
|
|||
}
|
||||
|
||||
for (SignalGroupV1Record insert : groupV1Inserts) {
|
||||
db.insertOrThrow(TABLE_NAME, null, getValuesForStorageGroupV1(insert));
|
||||
long id = db.insertWithOnConflict(TABLE_NAME, null, getValuesForStorageGroupV1(insert), SQLiteDatabase.CONFLICT_IGNORE);
|
||||
|
||||
if (id < 0) {
|
||||
Log.w(TAG, "Duplicate GV1 entry detected! Ignoring, suggesting force-push.");
|
||||
forcePush = true;
|
||||
} else {
|
||||
Recipient recipient = Recipient.externalGroupExact(context, GroupId.v1orThrow(insert.getGroupId()));
|
||||
|
||||
threadDatabase.applyStorageSyncUpdate(recipient.getId(), insert);
|
||||
needsRefresh.add(recipient.getId());
|
||||
}
|
||||
}
|
||||
|
||||
for (RecordUpdate<SignalGroupV1Record> update : groupV1Updates) {
|
||||
ContentValues values = getValuesForStorageGroupV1(update.getNew());
|
||||
|
@ -1017,6 +1023,8 @@ public class RecipientDatabase extends Database {
|
|||
for (RecipientId id : needsRefresh) {
|
||||
Recipient.live(id).refresh();
|
||||
}
|
||||
|
||||
return forcePush;
|
||||
}
|
||||
|
||||
public void applyStorageSyncUpdates(@NonNull StorageId storageId, SignalAccountRecord update) {
|
||||
|
|
|
@ -198,7 +198,7 @@ public class StorageSyncJob extends BaseJob {
|
|||
}
|
||||
|
||||
migrateToGv2IfNecessary(context, mergeResult.getLocalGroupV2Inserts());
|
||||
recipientDatabase.applyStorageSyncUpdates(mergeResult.getLocalContactInserts(), mergeResult.getLocalContactUpdates(), mergeResult.getLocalGroupV1Inserts(), mergeResult.getLocalGroupV1Updates(), mergeResult.getLocalGroupV2Inserts(), mergeResult.getLocalGroupV2Updates());
|
||||
needsForcePush |= recipientDatabase.applyStorageSyncUpdates(mergeResult.getLocalContactInserts(), mergeResult.getLocalContactUpdates(), mergeResult.getLocalGroupV1Inserts(), mergeResult.getLocalGroupV1Updates(), mergeResult.getLocalGroupV2Inserts(), mergeResult.getLocalGroupV2Updates());
|
||||
storageKeyDatabase.applyStorageSyncUpdates(mergeResult.getLocalUnknownInserts(), mergeResult.getLocalUnknownDeletes());
|
||||
StorageSyncHelper.applyAccountStorageSyncUpdates(context, mergeResult.getLocalAccountUpdate());
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue