mirror of
https://github.com/chatmail/core.git
synced 2026-05-09 01:46:30 +03:00
label blocking tasks (some spawn the task over Handle::current().spawn_blocking(), I marked those with a todo comment until I understand why it doesn't use the normal method)
This commit is contained in:
@@ -251,6 +251,7 @@ async fn generate_keypair(context: &Context) -> Result<KeyPair> {
|
|||||||
let keytype = KeyGenType::from_i32(context.get_config_int(Config::KeyGenType).await?)
|
let keytype = KeyGenType::from_i32(context.get_config_int(Config::KeyGenType).await?)
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
info!(context, "Generating keypair with type {}", keytype);
|
info!(context, "Generating keypair with type {}", keytype);
|
||||||
|
// TODO? add it here as well?
|
||||||
let keypair = Handle::current()
|
let keypair = Handle::current()
|
||||||
.spawn_blocking(move || crate::pgp::create_keypair(addr, keytype))
|
.spawn_blocking(move || crate::pgp::create_keypair(addr, keytype))
|
||||||
.await??;
|
.await??;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ use tokio::runtime::Handle;
|
|||||||
|
|
||||||
use crate::constants::KeyGenType;
|
use crate::constants::KeyGenType;
|
||||||
use crate::key::{DcKey, Fingerprint};
|
use crate::key::{DcKey, Fingerprint};
|
||||||
|
use crate::spawn_named_blocking_task;
|
||||||
|
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@@ -250,6 +251,7 @@ pub async fn pk_encrypt(
|
|||||||
) -> Result<String> {
|
) -> Result<String> {
|
||||||
let lit_msg = Message::new_literal_bytes("", plain);
|
let lit_msg = Message::new_literal_bytes("", plain);
|
||||||
|
|
||||||
|
// TODO? label this
|
||||||
Handle::current()
|
Handle::current()
|
||||||
.spawn_blocking(move || {
|
.spawn_blocking(move || {
|
||||||
let pkeys: Vec<SignedPublicKeyOrSubkey> = public_keys_for_encryption
|
let pkeys: Vec<SignedPublicKeyOrSubkey> = public_keys_for_encryption
|
||||||
@@ -367,7 +369,7 @@ pub async fn symm_encrypt(passphrase: &str, plain: &[u8]) -> Result<String> {
|
|||||||
let lit_msg = Message::new_literal_bytes("", plain);
|
let lit_msg = Message::new_literal_bytes("", plain);
|
||||||
let passphrase = passphrase.to_string();
|
let passphrase = passphrase.to_string();
|
||||||
|
|
||||||
tokio::task::spawn_blocking(move || {
|
spawn_named_blocking_task!("symm_encrypt", move || {
|
||||||
let mut rng = thread_rng();
|
let mut rng = thread_rng();
|
||||||
let s2k = StringToKey::new_default(&mut rng);
|
let s2k = StringToKey::new_default(&mut rng);
|
||||||
let msg =
|
let msg =
|
||||||
@@ -388,7 +390,7 @@ pub async fn symm_decrypt<T: std::io::Read + std::io::Seek>(
|
|||||||
let (enc_msg, _) = Message::from_armor_single(ctext)?;
|
let (enc_msg, _) = Message::from_armor_single(ctext)?;
|
||||||
|
|
||||||
let passphrase = passphrase.to_string();
|
let passphrase = passphrase.to_string();
|
||||||
tokio::task::spawn_blocking(move || {
|
spawn_named_blocking_task!("symm_decrypt", move || {
|
||||||
let msg = enc_msg.decrypt_with_password(|| passphrase)?;
|
let msg = enc_msg.decrypt_with_password(|| passphrase)?;
|
||||||
|
|
||||||
match msg.get_content()? {
|
match msg.get_content()? {
|
||||||
|
|||||||
Reference in New Issue
Block a user