mirror of
https://github.com/chatmail/core.git
synced 2026-05-22 16:26:31 +03:00
refactor: get rid of ctx1 variables using rebinding
This commit is contained in:
committed by
link2xt
parent
5e8e77dfb6
commit
3c387a3cb3
18
src/key.rs
18
src/key.rs
@@ -592,13 +592,14 @@ i8pcjGO+IZffvyZJVRWfVooBJmWWbPB1pueo3tx8w3+fcuzpxz+RLFKaPyqXO+dD
|
||||
t.set_config(Config::ConfiguredAddr, Some("alice@example.com"))
|
||||
.await
|
||||
.unwrap();
|
||||
let thr0 = {
|
||||
let ctx = t.clone();
|
||||
let ctx0 = ctx.clone();
|
||||
let thr0 =
|
||||
thread::spawn(move || async_std::task::block_on(SignedPublicKey::load_self(&ctx0)));
|
||||
let ctx1 = ctx;
|
||||
let thr1 =
|
||||
thread::spawn(move || async_std::task::block_on(SignedPublicKey::load_self(&ctx1)));
|
||||
thread::spawn(move || async_std::task::block_on(SignedPublicKey::load_self(&ctx)))
|
||||
};
|
||||
let thr1 = {
|
||||
let ctx = t.clone();
|
||||
thread::spawn(move || async_std::task::block_on(SignedPublicKey::load_self(&ctx)))
|
||||
};
|
||||
let res0 = thr0.join().unwrap();
|
||||
let res1 = thr1.join().unwrap();
|
||||
assert_eq!(res0.unwrap(), res1.unwrap());
|
||||
@@ -617,10 +618,9 @@ i8pcjGO+IZffvyZJVRWfVooBJmWWbPB1pueo3tx8w3+fcuzpxz+RLFKaPyqXO+dD
|
||||
let t = TestContext::new().await;
|
||||
let ctx = Arc::new(t);
|
||||
|
||||
let ctx1 = ctx.clone();
|
||||
let nrows = || async {
|
||||
ctx1.sql
|
||||
.query_get_value::<u32>(&ctx1, "SELECT COUNT(*) FROM keypairs;", paramsv![])
|
||||
ctx.sql
|
||||
.query_get_value::<u32>(&ctx, "SELECT COUNT(*) FROM keypairs;", paramsv![])
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
@@ -52,10 +52,10 @@ async fn inbox_loop(ctx: Context, started: Sender<()>, inbox_handlers: ImapConne
|
||||
shutdown_sender,
|
||||
} = inbox_handlers;
|
||||
|
||||
let ctx1 = ctx.clone();
|
||||
let fut = async move {
|
||||
let fut = {
|
||||
let ctx = ctx.clone();
|
||||
async move {
|
||||
started.send(()).await;
|
||||
let ctx = ctx1;
|
||||
|
||||
// track number of continously executed jobs
|
||||
let mut jobs_loaded = 0;
|
||||
@@ -94,6 +94,7 @@ async fn inbox_loop(ctx: Context, started: Sender<()>, inbox_handlers: ImapConne
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
stop_receiver
|
||||
@@ -179,15 +180,15 @@ async fn simple_imap_loop(
|
||||
shutdown_sender,
|
||||
} = inbox_handlers;
|
||||
|
||||
let ctx1 = ctx.clone();
|
||||
|
||||
let fut = async move {
|
||||
let fut = {
|
||||
let ctx = ctx.clone();
|
||||
async move {
|
||||
started.send(()).await;
|
||||
let ctx = ctx1;
|
||||
|
||||
loop {
|
||||
fetch_idle(&ctx, &mut connection, folder).await;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
stop_receiver
|
||||
@@ -211,10 +212,10 @@ async fn smtp_loop(ctx: Context, started: Sender<()>, smtp_handlers: SmtpConnect
|
||||
idle_interrupt_receiver,
|
||||
} = smtp_handlers;
|
||||
|
||||
let ctx1 = ctx.clone();
|
||||
let fut = async move {
|
||||
let fut = {
|
||||
let ctx = ctx.clone();
|
||||
async move {
|
||||
started.send(()).await;
|
||||
let ctx = ctx1;
|
||||
|
||||
let mut interrupt_info = Default::default();
|
||||
loop {
|
||||
@@ -232,6 +233,7 @@ async fn smtp_loop(ctx: Context, started: Sender<()>, smtp_handlers: SmtpConnect
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
stop_receiver
|
||||
@@ -259,16 +261,18 @@ impl Scheduler {
|
||||
let mut sentbox_handle = None;
|
||||
let (smtp_start_send, smtp_start_recv) = channel(1);
|
||||
|
||||
let ctx1 = ctx.clone();
|
||||
let inbox_handle = Some(task::spawn(async move {
|
||||
inbox_loop(ctx1, inbox_start_send, inbox_handlers).await
|
||||
}));
|
||||
let inbox_handle = {
|
||||
let ctx = ctx.clone();
|
||||
Some(task::spawn(async move {
|
||||
inbox_loop(ctx, inbox_start_send, inbox_handlers).await
|
||||
}))
|
||||
};
|
||||
|
||||
if ctx.get_config_bool(Config::MvboxWatch).await {
|
||||
let ctx1 = ctx.clone();
|
||||
let ctx = ctx.clone();
|
||||
mvbox_handle = Some(task::spawn(async move {
|
||||
simple_imap_loop(
|
||||
ctx1,
|
||||
ctx,
|
||||
mvbox_start_send,
|
||||
mvbox_handlers,
|
||||
Config::ConfiguredMvboxFolder,
|
||||
@@ -280,10 +284,10 @@ impl Scheduler {
|
||||
}
|
||||
|
||||
if ctx.get_config_bool(Config::SentboxWatch).await {
|
||||
let ctx1 = ctx.clone();
|
||||
let ctx = ctx.clone();
|
||||
sentbox_handle = Some(task::spawn(async move {
|
||||
simple_imap_loop(
|
||||
ctx1,
|
||||
ctx,
|
||||
sentbox_start_send,
|
||||
sentbox_handlers,
|
||||
Config::ConfiguredSentboxFolder,
|
||||
@@ -294,10 +298,12 @@ impl Scheduler {
|
||||
sentbox_start_send.send(()).await;
|
||||
}
|
||||
|
||||
let ctx1 = ctx.clone();
|
||||
let smtp_handle = Some(task::spawn(async move {
|
||||
smtp_loop(ctx1, smtp_start_send, smtp_handlers).await
|
||||
}));
|
||||
let smtp_handle = {
|
||||
let ctx = ctx.clone();
|
||||
Some(task::spawn(async move {
|
||||
smtp_loop(ctx, smtp_start_send, smtp_handlers).await
|
||||
}))
|
||||
};
|
||||
|
||||
*self = Scheduler::Running {
|
||||
inbox,
|
||||
|
||||
Reference in New Issue
Block a user