mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-26 20:55:10 +00:00
Fix storage sync issue related to duplicate remote contacts.
The theory is that if multiple remote keys map to the *same* local entry, then when we go to update the local contact the second time, we won't find the entry by StorageID, because we changed it during the *first* update, which will then lead to a crash. This change makes it so dupes are considered invalid, so we'll delete them and upload our own local copy.
This commit is contained in:
@@ -150,6 +150,16 @@ public class ContactConflictMergerTest {
|
||||
assertEquals(local, merged);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getInvalidEntries_nothingInvalid() {
|
||||
SignalContactRecord a = new SignalContactRecord.Builder(byteArray(1), new SignalServiceAddress(UUID_A, E164_A)).build();
|
||||
SignalContactRecord b = new SignalContactRecord.Builder(byteArray(2), new SignalServiceAddress(UUID_B, E164_B)).build();
|
||||
|
||||
Collection<SignalContactRecord> invalid = new ContactConflictMerger(Collections.emptyList(), SELF).getInvalidEntries(setOf(a, b));
|
||||
|
||||
assertContentsEqual(setOf(), invalid);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getInvalidEntries_selfIsInvalid() {
|
||||
SignalContactRecord a = new SignalContactRecord.Builder(byteArray(1), new SignalServiceAddress(UUID_A, E164_A)).build();
|
||||
@@ -160,4 +170,17 @@ public class ContactConflictMergerTest {
|
||||
|
||||
assertContentsEqual(setOf(self), invalid);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getInvalidEntries_duplicatesInvalid() {
|
||||
SignalContactRecord aLocal = new SignalContactRecord.Builder(byteArray(1), new SignalServiceAddress(UUID_A, E164_A)).build();
|
||||
SignalContactRecord bRemote = new SignalContactRecord.Builder(byteArray(2), new SignalServiceAddress(UUID_B, E164_B)).build();
|
||||
SignalContactRecord aRemote1 = new SignalContactRecord.Builder(byteArray(3), new SignalServiceAddress(UUID_A, null)).build();
|
||||
SignalContactRecord aRemote2 = new SignalContactRecord.Builder(byteArray(4), new SignalServiceAddress(null, E164_A)).build();
|
||||
SignalContactRecord aRemote3 = new SignalContactRecord.Builder(byteArray(5), new SignalServiceAddress(UUID_A, E164_A)).build();
|
||||
|
||||
Collection<SignalContactRecord> invalid = new ContactConflictMerger(Collections.singleton(aLocal), SELF).getInvalidEntries(setOf(aRemote1, aRemote2, aRemote3, bRemote));
|
||||
|
||||
assertContentsEqual(setOf(aRemote1, aRemote2, aRemote3), invalid);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user