Skip to content

Commit ec2b088

Browse files
committed
chore: update rusqlite from 0.37 to 0.40
Largest change comes from removal of u64 and usize serialization in rusqlite 0.38.0. It is possible to enable it back with `fallible_uint` feature as suggested in rusqlite/rusqlite#1732, but there is a good reason for this change as it may result in unexpected failures when trying to store u64 integers that don't fit in i64, so I don't enable it back. With this change conversions between i64 and u64 are explicit. Using less `usize` is generally good as its size differs on 32-bit platforms that are rarely tested but still supported and we have changes that reduce its usage such as 0defa11, 014d2ac etc.
1 parent a797588 commit ec2b088

9 files changed

Lines changed: 109 additions & 60 deletions

File tree

Cargo.lock

Lines changed: 74 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ nu-ansi-term = "0.50"
194194
num-traits = "0.2"
195195
rand = "0.9"
196196
regex = "1.12"
197-
rusqlite = "0.37"
197+
rusqlite = "0.40"
198198
sanitize-filename = "0.6"
199199
serde = "1.0"
200200
serde_json = "1"

deny.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ skip = [
6969
{ name = "derive_more-impl", version = "1.0.0" },
7070
{ name = "derive_more", version = "1.0.0" },
7171
{ name = "event-listener", version = "2.5.3" },
72+
{ name = "foldhash", version = "0.1.5" },
7273
{ name = "getrandom", version = "0.2.12" },
74+
{ name = "hashbrown", version = "0.15.4" },
75+
{ name = "hashbrown", version = "0.16.1" },
7376
{ name = "heck", version = "0.4.1" },
7477
{ name = "http", version = "0.2.12" },
7578
{ name = "hybrid-array", version = "0.2.3" },

src/constants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ Here is what to do:
234234
If you have any questions, please send an email to delta@merlinux.eu or ask at https://support.delta.chat/."#;
235235

236236
/// How many recent messages should be re-sent to a new broadcast member.
237-
pub(crate) const N_MSGS_TO_NEW_BROADCAST_MEMBER: usize = 10;
237+
pub(crate) const N_MSGS_TO_NEW_BROADCAST_MEMBER: u32 = 10;
238238

239239
#[cfg(test)]
240240
mod tests {

src/net.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use tls::wrap_tls;
3333
pub(crate) const TIMEOUT: Duration = Duration::from_secs(60);
3434

3535
/// TTL for caches in seconds.
36-
pub(crate) const CACHE_TTL: u64 = 30 * 24 * 60 * 60;
36+
pub(crate) const CACHE_TTL: u32 = 30 * 24 * 60 * 60;
3737

3838
/// Removes connection history entries after `CACHE_TTL`.
3939
pub(crate) async fn prune_connection_history(context: &Context) -> Result<()> {

src/receive_imf.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2737,6 +2737,12 @@ async fn lookup_or_create_adhoc_group(
27372737
for &id in &contact_ids {
27382738
stmt.execute((id,)).context("INSERT INTO temp.contacts")?;
27392739
}
2740+
2741+
// Contact IDs are 32-bit internally,
2742+
// so this conversion of contact ID set size
2743+
// to u32 should never fail.
2744+
let contact_ids_len = u32::try_from(contact_ids.len())?;
2745+
27402746
let val = t
27412747
.query_row(
27422748
"SELECT c.id, c.blocked
@@ -2750,7 +2756,7 @@ async fn lookup_or_create_adhoc_group(
27502756
AND contact_id NOT IN (SELECT id FROM temp.contacts)
27512757
AND add_timestamp >= remove_timestamp)=0
27522758
ORDER BY m.timestamp DESC",
2753-
(&grpname, contact_ids.len()),
2759+
(&grpname, contact_ids_len),
27542760
|row| {
27552761
let id: ChatId = row.get(0)?;
27562762
let blocked: Blocked = row.get(1)?;

src/sql/migrations.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ pub(crate) async fn msgs_to_key_contacts(context: &Context) -> Result<()> {
658658
return Ok(());
659659
}
660660
let trans_fn = |t: &mut rusqlite::Transaction| {
661-
let mut first_key_contacts_msg_id: u64 = t
661+
let mut first_key_contacts_msg_id: u32 = t
662662
.query_one(
663663
"SELECT CAST(value AS INTEGER) FROM config WHERE keyname='first_key_contacts_msg_id'",
664664
(),
@@ -682,10 +682,10 @@ pub(crate) async fn msgs_to_key_contacts(context: &Context) -> Result<()> {
682682
)
683683
.context("Prepare stmt")?;
684684
let msgs_to_migrate = 1000;
685-
let mut msgs_migrated: u64 = 0;
685+
let mut msgs_migrated: u32 = 0;
686686
while first_key_contacts_msg_id > 0 && msgs_migrated < msgs_to_migrate {
687687
let start_msg_id = first_key_contacts_msg_id.saturating_sub(msgs_to_migrate);
688-
let cnt: u64 = stmt
688+
let cnt: u32 = stmt
689689
.execute((start_msg_id, first_key_contacts_msg_id))
690690
.context("UPDATE msgs")?
691691
.try_into()?;

src/stats.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ struct ContactStat {
7777
#[serde(skip_serializing_if = "is_false")]
7878
direct_chat: bool,
7979

80-
last_seen: u64,
80+
last_seen: i64,
8181

8282
#[serde(skip_serializing_if = "Option::is_none")]
8383
transitive_chain: Option<u32>,
@@ -328,7 +328,7 @@ async fn ensure_last_old_contact_id(context: &Context) -> Result<()> {
328328
return Ok(());
329329
}
330330

331-
let last_contact_id: u64 = context
331+
let last_contact_id: u32 = context
332332
.sql
333333
.query_get_value("SELECT MAX(id) FROM contacts", ())
334334
.await?
@@ -451,7 +451,7 @@ async fn get_contact_stats(context: &Context, last_old_contact: u32) -> Result<V
451451
let id = row.get(0)?;
452452
let is_encrypted: bool = row.get(1)?;
453453
let verifier: ContactId = row.get(2)?;
454-
let last_seen: u64 = row.get(3)?;
454+
let last_seen: i64 = row.get(3)?;
455455
let bot: bool = row.get(4)?;
456456

457457
let verified = match (is_encrypted, verifier) {

0 commit comments

Comments
 (0)