WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/matrix-sdk-sqlite/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "matrix-sdk-sqlite"
version = "0.16.0"
edition = "2021"
edition = "2024"
repository = "https://github.com/matrix-org/matrix-rust-sdk"
description = "Sqlite storage backend for matrix-sdk"
license = "Apache-2.0"
Expand Down
26 changes: 11 additions & 15 deletions crates/matrix-sdk-sqlite/src/crypto_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,37 @@ use std::{
use async_trait::async_trait;
use matrix_sdk_base::cross_process_lock::CrossProcessLockGeneration;
use matrix_sdk_crypto::{
Account, DeviceData, GossipRequest, GossippedSecret, SecretInfo, TrackedUser, UserIdentityData,
olm::{
InboundGroupSession, OutboundGroupSession, PickledInboundGroupSession,
PrivateCrossSigningIdentity, SenderDataType, Session, StaticAccountData,
},
store::{
CryptoStore,
types::{
BackupKeys, Changes, DehydratedDeviceKey, PendingChanges, RoomKeyCounts,
RoomKeyWithheldEntry, RoomSettings, StoredRoomKeyBundleData,
},
CryptoStore,
},
Account, DeviceData, GossipRequest, GossippedSecret, SecretInfo, TrackedUser, UserIdentityData,
};
use matrix_sdk_store_encryption::StoreCipher;
use ruma::{
events::secret::request::SecretName, DeviceId, MilliSecondsSinceUnixEpoch, OwnedDeviceId,
RoomId, TransactionId, UserId,
DeviceId, MilliSecondsSinceUnixEpoch, OwnedDeviceId, RoomId, TransactionId, UserId,
events::secret::request::SecretName,
};
use rusqlite::{named_params, params_from_iter, OptionalExtension};
use rusqlite::{OptionalExtension, named_params, params_from_iter};
use tokio::{fs, sync::Mutex};
use tracing::{debug, instrument, warn};
use vodozemac::Curve25519PublicKey;

use crate::{
OpenStoreError, Secret, SqliteStoreConfig,
connection::{Connection as SqliteAsyncConn, Pool as SqlitePool},
error::{Error, Result},
utils::{
repeat_vars, EncryptableStore, Key, SqliteAsyncConnExt, SqliteKeyValueStoreAsyncConnExt,
SqliteKeyValueStoreConnExt,
EncryptableStore, Key, SqliteAsyncConnExt, SqliteKeyValueStoreAsyncConnExt,
SqliteKeyValueStoreConnExt, repeat_vars,
},
OpenStoreError, Secret, SqliteStoreConfig,
};

/// The database name.
Expand Down Expand Up @@ -1066,11 +1066,7 @@ impl CryptoStore for SqliteCryptoStore {
})
.collect::<Result<_>>()?;

if sessions.is_empty() {
Ok(None)
} else {
Ok(Some(sessions))
}
if sessions.is_empty() { Ok(None) } else { Ok(Some(sessions)) }
}

#[instrument(skip(self))]
Expand Down Expand Up @@ -1568,7 +1564,7 @@ mod tests {
use once_cell::sync::Lazy;
use ruma::{device_id, room_id, user_id};
use similar_asserts::assert_eq;
use tempfile::{tempdir, TempDir};
use tempfile::{TempDir, tempdir};
use tokio::fs;

use super::SqliteCryptoStore;
Expand Down Expand Up @@ -1980,7 +1976,7 @@ mod tests {
mod encrypted_tests {
use matrix_sdk_crypto::{cryptostore_integration_tests, cryptostore_integration_tests_time};
use once_cell::sync::Lazy;
use tempfile::{tempdir, TempDir};
use tempfile::{TempDir, tempdir};
use tokio::fs;

use super::SqliteCryptoStore;
Expand Down
18 changes: 9 additions & 9 deletions crates/matrix-sdk-sqlite/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ macro_rules! impl_from {

impl From<rusqlite::Error> for Error {
fn from(error: rusqlite::Error) -> Self {
if let rusqlite::Error::SqliteFailure(ffi_error, message) = &error {
if ffi_error.code == rusqlite::ErrorCode::DatabaseBusy {
// Report to sentry.
tracing::error!(
sentry = true,
sqlite_message = message,
"observed database busy error"
);
}
if let rusqlite::Error::SqliteFailure(ffi_error, message) = &error
&& ffi_error.code == rusqlite::ErrorCode::DatabaseBusy
{
// Report to sentry.
tracing::error!(
sentry = true,
sqlite_message = message,
"observed database busy error"
);
}
Error::Sqlite(error)
}
Expand Down
30 changes: 14 additions & 16 deletions crates/matrix-sdk-sqlite/src/event_cache_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use matrix_sdk_base::{
cross_process_lock::CrossProcessLockGeneration,
deserialized_responses::TimelineEvent,
event_cache::{
store::{extract_event_relation, EventCacheStore},
Event, Gap,
store::{EventCacheStore, extract_event_relation},
},
linked_chunk::{
ChunkContent, ChunkIdentifier, ChunkIdentifierGenerator, ChunkMetadata, LinkedChunkId,
Expand All @@ -32,10 +32,10 @@ use matrix_sdk_base::{
};
use matrix_sdk_store_encryption::StoreCipher;
use ruma::{
events::relation::RelationType, EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, RoomId,
EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, RoomId, events::relation::RelationType,
};
use rusqlite::{
params, params_from_iter, OptionalExtension, ToSql, Transaction, TransactionBehavior,
OptionalExtension, ToSql, Transaction, TransactionBehavior, params, params_from_iter,
};
use tokio::{
fs,
Expand All @@ -44,13 +44,13 @@ use tokio::{
use tracing::{debug, error, instrument, trace};

use crate::{
OpenStoreError, Secret, SqliteStoreConfig,
connection::{Connection as SqliteAsyncConn, Pool as SqlitePool},
error::{Error, Result},
utils::{
repeat_vars, EncryptableStore, Key, SqliteAsyncConnExt, SqliteKeyValueStoreAsyncConnExt,
SqliteKeyValueStoreConnExt, SqliteTransactionExt,
EncryptableStore, Key, SqliteAsyncConnExt, SqliteKeyValueStoreAsyncConnExt,
SqliteKeyValueStoreConnExt, SqliteTransactionExt, repeat_vars,
},
OpenStoreError, Secret, SqliteStoreConfig,
};

mod keys {
Expand Down Expand Up @@ -1481,7 +1481,7 @@ fn find_event_relations_transaction(
Ok(related)
};

let related = if let Some(filters) = filters {
if let Some(filters) = filters {
let question_marks = repeat_vars(filters.len());
let query = format!(
"SELECT events.content, event_chunks.chunk_id, event_chunks.position
Expand Down Expand Up @@ -1533,9 +1533,7 @@ fn find_event_relations_transaction(
let transaction = transaction.query_map(parameters, get_rows)?;

collect_results(transaction)
};

related
}
}

/// Like `deadpool::managed::Object::with_transaction`, but starts the
Expand Down Expand Up @@ -1631,27 +1629,27 @@ mod tests {
use assert_matches::assert_matches;
use matrix_sdk_base::{
event_cache::{
Gap,
store::{
EventCacheStore, EventCacheStoreError,
integration_tests::{
check_test_event, make_test_event, make_test_event_with_event_id,
},
EventCacheStore, EventCacheStoreError,
},
Gap,
},
event_cache_store_integration_tests, event_cache_store_integration_tests_time,
linked_chunk::{ChunkContent, ChunkIdentifier, LinkedChunkId, Position, Update},
};
use matrix_sdk_test::{async_test, DEFAULT_TEST_ROOM_ID};
use matrix_sdk_test::{DEFAULT_TEST_ROOM_ID, async_test};
use once_cell::sync::Lazy;
use ruma::{event_id, room_id};
use tempfile::{tempdir, TempDir};
use tempfile::{TempDir, tempdir};

use super::SqliteEventCacheStore;
use crate::{
SqliteStoreConfig,
event_cache_store::keys,
utils::{EncryptableStore as _, SqliteAsyncConnExt},
SqliteStoreConfig,
};

static TMP_DIR: Lazy<TempDir> = Lazy::new(|| tempdir().unwrap());
Expand Down Expand Up @@ -2537,7 +2535,7 @@ mod encrypted_tests {
events::{relation::RelationType, room::message::RoomMessageEventContentWithoutRelation},
room_id, user_id,
};
use tempfile::{tempdir, TempDir};
use tempfile::{TempDir, tempdir};

use super::SqliteEventCacheStore;

Expand Down
4 changes: 2 additions & 2 deletions crates/matrix-sdk-sqlite/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub use self::event_cache_store::SqliteEventCacheStore;
#[cfg(feature = "event-cache")]
pub use self::media_store::SqliteMediaStore;
#[cfg(feature = "state-store")]
pub use self::state_store::{SqliteStateStore, DATABASE_NAME as STATE_STORE_DATABASE_NAME};
pub use self::state_store::{DATABASE_NAME as STATE_STORE_DATABASE_NAME, SqliteStateStore};

#[cfg(test)]
matrix_sdk_test_utils::init_tracing_for_tests!();
Expand Down Expand Up @@ -263,7 +263,7 @@ mod tests {
path::{Path, PathBuf},
};

use super::{Secret, SqliteStoreConfig, POOL_MINIMUM_SIZE};
use super::{POOL_MINIMUM_SIZE, Secret, SqliteStoreConfig};

#[test]
fn test_new() {
Expand Down
20 changes: 10 additions & 10 deletions crates/matrix-sdk-sqlite/src/media_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,31 @@ use async_trait::async_trait;
use matrix_sdk_base::{
cross_process_lock::CrossProcessLockGeneration,
media::{
MediaRequestParameters, UniqueKey,
store::{
IgnoreMediaRetentionPolicy, MediaRetentionPolicy, MediaService, MediaStore,
MediaStoreInner,
},
MediaRequestParameters, UniqueKey,
},
timer,
};
use matrix_sdk_store_encryption::StoreCipher;
use ruma::{time::SystemTime, MilliSecondsSinceUnixEpoch, MxcUri};
use rusqlite::{params_from_iter, OptionalExtension};
use ruma::{MilliSecondsSinceUnixEpoch, MxcUri, time::SystemTime};
use rusqlite::{OptionalExtension, params_from_iter};
use tokio::{
fs,
sync::{Mutex, OwnedMutexGuard},
};
use tracing::{debug, instrument};

use crate::{
OpenStoreError, Secret, SqliteStoreConfig,
connection::{Connection as SqliteAsyncConn, Pool as SqlitePool},
error::{Error, Result},
utils::{
repeat_vars, time_to_timestamp, EncryptableStore, SqliteAsyncConnExt,
SqliteKeyValueStoreAsyncConnExt, SqliteKeyValueStoreConnExt, SqliteTransactionExt,
EncryptableStore, SqliteAsyncConnExt, SqliteKeyValueStoreAsyncConnExt,
SqliteKeyValueStoreConnExt, SqliteTransactionExt, repeat_vars, time_to_timestamp,
},
OpenStoreError, Secret, SqliteStoreConfig,
};

mod keys {
Expand Down Expand Up @@ -680,19 +680,19 @@ mod tests {

use matrix_sdk_base::{
media::{
store::{IgnoreMediaRetentionPolicy, MediaStore, MediaStoreError},
MediaFormat, MediaRequestParameters, MediaThumbnailSettings,
store::{IgnoreMediaRetentionPolicy, MediaStore, MediaStoreError},
},
media_store_inner_integration_tests, media_store_integration_tests,
media_store_integration_tests_time,
};
use matrix_sdk_test::async_test;
use once_cell::sync::Lazy;
use ruma::{events::room::MediaSource, media::Method, mxc_uri, uint};
use tempfile::{tempdir, TempDir};
use tempfile::{TempDir, tempdir};

use super::SqliteMediaStore;
use crate::{utils::SqliteAsyncConnExt, SqliteStoreConfig};
use crate::{SqliteStoreConfig, utils::SqliteAsyncConnExt};

static TMP_DIR: Lazy<TempDir> = Lazy::new(|| tempdir().unwrap());
static NUM: AtomicU32 = AtomicU32::new(0);
Expand Down Expand Up @@ -811,7 +811,7 @@ mod encrypted_tests {
media_store_integration_tests, media_store_integration_tests_time,
};
use once_cell::sync::Lazy;
use tempfile::{tempdir, TempDir};
use tempfile::{TempDir, tempdir};

use super::SqliteMediaStore;

Expand Down
Loading
Loading