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

@@ -15,6 +15,7 @@ use tokio_util::task::TaskTracker;
use self::connectivity::ConnectivityStore;
use crate::config::{self, Config};
use crate::constants;
use crate::contact::{ContactId, RecentlySeenLoop};
use crate::context::Context;
use crate::download::{DownloadState, download_msg};
@@ -497,7 +498,8 @@ async fn inbox_fetch_idle(ctx: &Context, imap: &mut Imap, mut session: Session)
match ctx.get_config_i64(Config::LastHousekeeping).await {
Ok(last_housekeeping_time) => {
let next_housekeeping_time = last_housekeeping_time.saturating_add(60 * 60 * 24);
let next_housekeeping_time =
last_housekeeping_time.saturating_add(constants::HOUSEKEEPING_PERIOD);
if next_housekeeping_time <= time() {
sql::housekeeping(ctx).await.log_err(ctx).ok();
}