diff --git a/CHANGELOG.md b/CHANGELOG.md index 002241c77..bc45d1c74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Changes - limit the rate of MDN sending #3402 +- remove `msgs_mdns` references to deleted messages during housekeeping #3387 ### Fixes - set a default error if NDN does not provide an error diff --git a/src/sql.rs b/src/sql.rs index 345a0cffa..f7f2a9df6 100644 --- a/src/sql.rs +++ b/src/sql.rs @@ -19,6 +19,7 @@ use crate::constants::DC_CHAT_ID_TRASH; use crate::context::Context; use crate::dc_tools::{dc_delete_file, time}; use crate::ephemeral::start_ephemeral_timers; +use crate::log::LogExt; use crate::message::{Message, Viewtype}; use crate::param::{Param, Params}; use crate::peerstate::{deduplicate_peerstates, Peerstate}; @@ -650,6 +651,15 @@ pub async fn housekeeping(context: &Context) -> Result<()> { warn!(context, "Can't set config: {}", e); } + context + .sql + .execute( + "DELETE FROM msgs_mdns WHERE msg_id NOT IN (SELECT id FROM msgs)", + paramsv![], + ) + .await + .ok_or_log_msg(context, "failed to remove old MDNs"); + info!(context, "Housekeeping done."); Ok(()) }