mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Prevent crash when receiving already migrated group v1 from storage
Fixes #1471
This commit is contained in:
parent
6c44662496
commit
57164ad7fb
2 changed files with 25 additions and 19 deletions
|
@ -229,6 +229,13 @@ public class GroupStore {
|
||||||
|
|
||||||
public GroupInfoV1 getOrCreateGroupV1(GroupIdV1 groupId) {
|
public GroupInfoV1 getOrCreateGroupV1(GroupIdV1 groupId) {
|
||||||
try (final var connection = database.getConnection()) {
|
try (final var connection = database.getConnection()) {
|
||||||
|
return getOrCreateGroupV1(connection, groupId);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException("Failed read from group store", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public GroupInfoV1 getOrCreateGroupV1(final Connection connection, final GroupIdV1 groupId) throws SQLException {
|
||||||
var group = getGroup(connection, groupId);
|
var group = getGroup(connection, groupId);
|
||||||
|
|
||||||
if (group != null) {
|
if (group != null) {
|
||||||
|
@ -240,9 +247,6 @@ public class GroupStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new RuntimeException("Failed read from group store", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GroupInfoV2 getGroupOrPartialMigrate(
|
public GroupInfoV2 getGroupOrPartialMigrate(
|
||||||
|
|
|
@ -112,7 +112,8 @@ public final class GroupV1RecordProcessor extends DefaultStorageRecordProcessor<
|
||||||
final var groupV1Record = update.newRecord();
|
final var groupV1Record = update.newRecord();
|
||||||
final var groupIdV1 = GroupId.v1(groupV1Record.getGroupId());
|
final var groupIdV1 = GroupId.v1(groupV1Record.getGroupId());
|
||||||
|
|
||||||
final var group = account.getGroupStore().getGroup(connection, groupIdV1);
|
final var group = account.getGroupStore().getOrCreateGroupV1(connection, groupIdV1);
|
||||||
|
if (group != null) {
|
||||||
group.setBlocked(groupV1Record.isBlocked());
|
group.setBlocked(groupV1Record.isBlocked());
|
||||||
account.getGroupStore().updateGroup(connection, group);
|
account.getGroupStore().updateGroup(connection, group);
|
||||||
account.getGroupStore()
|
account.getGroupStore()
|
||||||
|
@ -121,6 +122,7 @@ public final class GroupV1RecordProcessor extends DefaultStorageRecordProcessor<
|
||||||
groupV1Record.getId(),
|
groupV1Record.getId(),
|
||||||
groupV1Record.toProto().encode());
|
groupV1Record.toProto().encode());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(SignalGroupV1Record lhs, SignalGroupV1Record rhs) {
|
public int compare(SignalGroupV1Record lhs, SignalGroupV1Record rhs) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue