fix: Save msgs to key-contacts migration state and run migration periodically (#6956)

Save:
- (old contact id) -> (new contact id) mapping.
- The message id starting from which all messages are already migrated.
Run the migration from `housekeeping()` for at least 500 ms and for >= 1000 messages per run.
This commit is contained in:
iequidoo
2025-07-06 16:40:16 -03:00
committed by iequidoo
parent a87ee030fc
commit 389649ea8a
5 changed files with 128 additions and 53 deletions

View File

@@ -581,6 +581,12 @@ impl Sql {
Ok(value)
}
/// Removes the `key`'s value from the cache.
pub(crate) async fn uncache_raw_config(&self, key: &str) {
let mut lock = self.config_cache.write().await;
lock.remove(key);
}
/// Sets configuration for the given key to 32-bit signed integer value.
pub async fn set_raw_config_int(&self, key: &str, value: i32) -> Result<()> {
self.set_raw_config(key, Some(&format!("{value}"))).await
@@ -724,6 +730,11 @@ pub async fn housekeeping(context: &Context) -> Result<()> {
.context("Failed to cleanup HTTP cache")
.log_err(context)
.ok();
migrations::msgs_to_key_contacts(context)
.await
.context("migrations::msgs_to_key_contacts")
.log_err(context)
.ok();
if let Err(err) = remove_unused_files(context).await {
warn!(