Skip to content

Commit

Permalink
Fix overlapping sqlite sessions in migration
Browse files Browse the repository at this point in the history
Fixes #1394
  • Loading branch information
AsamK committed Dec 11, 2023
1 parent a2f5224 commit 6efca4f
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,6 @@ public Profile getProfile(final RecipientId recipientId) {

@Override
public ProfileKey getProfileKey(final RecipientId recipientId) {
final var selfRecipientId = resolveRecipient(selfAddressProvider.getSelfAddress());
if (recipientId.equals(selfRecipientId)) {
return selfProfileKeyProvider.getSelfProfileKey();
}
try (final var connection = database.getConnection()) {
return getProfileKey(connection, recipientId);
} catch (SQLException e) {
Expand Down Expand Up @@ -662,9 +658,9 @@ private void storeProfileKey(
Connection connection, RecipientId recipientId, final ProfileKey profileKey, boolean resetProfile
) throws SQLException {
if (profileKey != null) {
final var recipientProfileKey = getProfileKey(recipientId);
final var recipientProfileKey = getProfileKey(connection, recipientId);
if (profileKey.equals(recipientProfileKey)) {
final var recipientProfile = getProfile(recipientId);
final var recipientProfile = getProfile(connection, recipientId);
if (recipientProfile == null || (
recipientProfile.getUnidentifiedAccessMode() != Profile.UnidentifiedAccessMode.UNKNOWN
&& recipientProfile.getUnidentifiedAccessMode()
Expand Down Expand Up @@ -985,6 +981,10 @@ private Contact getContact(final Connection connection, final RecipientId recipi
}

private ProfileKey getProfileKey(final Connection connection, final RecipientId recipientId) throws SQLException {
final var selfRecipientId = resolveRecipientLocked(connection, selfAddressProvider.getSelfAddress());
if (recipientId.equals(selfRecipientId)) {
return selfProfileKeyProvider.getSelfProfileKey();
}
final var sql = (
"""
SELECT r.profile_key
Expand Down

0 comments on commit 6efca4f

Please sign in to comment.