From bddc88472a570ca34084cca30b0855c38df97caa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Fri, 16 Jun 2023 16:32:46 +0200 Subject: [PATCH] Clarify the comment about creating a Olm session twice Co-authored-by: Denis Kasak --- crates/matrix-sdk-crypto/src/olm/account.rs | 13 ++++++------- .../src/session_manager/sessions.rs | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/crates/matrix-sdk-crypto/src/olm/account.rs b/crates/matrix-sdk-crypto/src/olm/account.rs index db3823795..7120d2d66 100644 --- a/crates/matrix-sdk-crypto/src/olm/account.rs +++ b/crates/matrix-sdk-crypto/src/olm/account.rs @@ -278,14 +278,13 @@ impl Account { // The message was intended for this session, but we weren't able to decrypt it. // // We're going to return early here since no other session will be able to - // decrypt this message, nor should we try to create a new one since we already - // created a `Session` with such a pre-key message. + // decrypt this message, nor should we try to create a new one since we had + // already previously created a `Session` with such a pre-key message. // - // Creating a new session will likely fail since the one-time key that should be - // used to establish the session will be used up. - // - // The one exception where creating a new session won't fail is if a fallback - // key was used for this `Session`. + // Creating this session would have likely failed anyway since the corresponding + // one-time key would've been already used up in the previous session creation + // operation. The one exception where this would not be so is if the fallback + // key was used for creating the session in lieu of an OTK. return Err(OlmError::SessionWedged( session.user_id.to_owned(), session.sender_key(), diff --git a/crates/matrix-sdk-crypto/src/session_manager/sessions.rs b/crates/matrix-sdk-crypto/src/session_manager/sessions.rs index 829870cd1..14f7a20cb 100644 --- a/crates/matrix-sdk-crypto/src/session_manager/sessions.rs +++ b/crates/matrix-sdk-crypto/src/session_manager/sessions.rs @@ -344,7 +344,7 @@ impl SessionManager { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( f, - "session_id: {}, algorithm: {}, fallback_key_used {}", + "session_id: {}, algorithm: {}, fallback_key_used: {}", self.session_id, self.algorithm, self.fallback_key_used ) }