Move removal of chat message tombstones to a separate function

DELETE operation may be slow compared to UPDATE. It is better to do in
a separate job.
This commit is contained in:
Alexander Krotov
2020-03-22 07:59:43 +03:00
parent 9febc762da
commit 9eb672ea17

View File

@@ -2521,18 +2521,22 @@ pub fn delete_device_expired_messages(context: &Context) -> sql::Result<()> {
WHERE timestamp < ?",
params![threshold_timestamp],
)?;
// Delete hidden messages that are removed from the server.
context.sql.execute(
"DELETE FROM msgs \
WHERE (chat_id = ? OR hidden) \
AND server_uid = 0",
params![DC_CHAT_ID_TRASH],
)?;
}
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)]
mod tests {
use super::*;