Skip invalid group records

Fixes #642
This commit is contained in:
AsamK 2021-06-12 08:47:18 +02:00
parent 39c4cf24b8
commit 0001a9b300

View file

@ -2240,7 +2240,16 @@ public class Manager implements Closeable {
try (var attachmentAsStream = retrieveAttachmentAsStream(groupsMessage.asPointer(), tmpFile)) { try (var attachmentAsStream = retrieveAttachmentAsStream(groupsMessage.asPointer(), tmpFile)) {
var s = new DeviceGroupsInputStream(attachmentAsStream); var s = new DeviceGroupsInputStream(attachmentAsStream);
DeviceGroup g; DeviceGroup g;
while ((g = s.read()) != null) { while (true) {
try {
g = s.read();
} catch (IOException e) {
logger.warn("Sync groups contained invalid group, ignoring: {}", e.getMessage());
continue;
}
if (g == null) {
break;
}
var syncGroup = account.getGroupStore().getOrCreateGroupV1(GroupId.v1(g.getId())); var syncGroup = account.getGroupStore().getOrCreateGroupV1(GroupId.v1(g.getId()));
if (syncGroup != null) { if (syncGroup != null) {
if (g.getName().isPresent()) { if (g.getName().isPresent()) {