mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
Move prune_tombstones() to sql:: and call from housekeeping()
This commit is contained in:
12
src/chat.rs
12
src/chat.rs
@@ -2529,18 +2529,6 @@ pub fn delete_device_expired_messages(context: &Context) -> sql::Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes from the database locally deleted messages that also don't
|
|
||||||
/// have a server UID.
|
|
||||||
pub fn prune_tombstones(context: &Context) -> sql::Result<()> {
|
|
||||||
context.sql.execute(
|
|
||||||
"DELETE FROM msgs \
|
|
||||||
WHERE (chat_id = ? OR hidden) \
|
|
||||||
AND server_uid = 0",
|
|
||||||
params![DC_CHAT_ID_TRASH],
|
|
||||||
)?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
21
src/sql.rs
21
src/sql.rs
@@ -8,7 +8,7 @@ use rusqlite::{Connection, OpenFlags, Statement, NO_PARAMS};
|
|||||||
use thread_local_object::ThreadLocal;
|
use thread_local_object::ThreadLocal;
|
||||||
|
|
||||||
use crate::chat::{update_device_icon, update_saved_messages_icon};
|
use crate::chat::{update_device_icon, update_saved_messages_icon};
|
||||||
use crate::constants::ShowEmails;
|
use crate::constants::{ShowEmails, DC_CHAT_ID_TRASH};
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::dc_tools::*;
|
use crate::dc_tools::*;
|
||||||
use crate::param::*;
|
use crate::param::*;
|
||||||
@@ -1053,6 +1053,18 @@ pub fn get_rowid2_with_conn(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Removes from the database locally deleted messages that also don't
|
||||||
|
/// have a server UID.
|
||||||
|
fn prune_tombstones(context: &Context) -> Result<()> {
|
||||||
|
context.sql.execute(
|
||||||
|
"DELETE FROM msgs \
|
||||||
|
WHERE (chat_id = ? OR hidden) \
|
||||||
|
AND server_uid = 0",
|
||||||
|
params![DC_CHAT_ID_TRASH],
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn housekeeping(context: &Context) {
|
pub fn housekeeping(context: &Context) {
|
||||||
let mut files_in_use = HashSet::new();
|
let mut files_in_use = HashSet::new();
|
||||||
let mut unreferenced_count = 0;
|
let mut unreferenced_count = 0;
|
||||||
@@ -1165,6 +1177,13 @@ pub fn housekeeping(context: &Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Err(err) = prune_tombstones(context) {
|
||||||
|
warn!(
|
||||||
|
context,
|
||||||
|
"Houskeeping: Cannot prune message tombstones: {}", err
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
info!(context, "Housekeeping done.",);
|
info!(context, "Housekeeping done.",);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user