diff --git a/Cargo.lock b/Cargo.lock index e481ce4..4f735ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -711,7 +711,7 @@ checksum = "a604f7a68fbf8103337523b1fadc8ade7361ee3f112f7c680ad179651616aed5" dependencies = [ "futures-core", "lock_api", - "parking_lot", + "parking_lot 0.11.2", ] [[package]] @@ -1318,7 +1318,17 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", - "parking_lot_core", + "parking_lot_core 0.8.6", +] + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core 0.9.8", ] [[package]] @@ -1330,11 +1340,24 @@ dependencies = [ "cfg-if", "instant", "libc", - "redox_syscall", + "redox_syscall 0.2.16", "smallvec", "winapi", ] +[[package]] +name = "parking_lot_core" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.3.5", + "smallvec", + "windows-targets", +] + [[package]] name = "pass_manager" version = "0.1.0" @@ -1348,6 +1371,7 @@ dependencies = [ "itertools 0.10.5", "log", "migration", + "parking_lot 0.12.1", "pretty_env_logger", "rayon", "sea-orm", @@ -1628,6 +1652,15 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "regex" version = "1.8.4" diff --git a/Cargo.toml b/Cargo.toml index 8a518f6..53e7db5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ futures = "0.3.28" itertools = "0.10.5" log = "0.4.17" migration = { version = "0.2.0", path = "migration" } +parking_lot = "0.12.1" pretty_env_logger = "0.5.0" rayon = "1.7.0" sea-orm = { version = "0.11.3", features = ["sqlx-mysql", "runtime-tokio-rustls"] } diff --git a/src/commands/export.rs b/src/commands/export.rs index a0c51de..c5dad72 100644 --- a/src/commands/export.rs +++ b/src/commands/export.rs @@ -6,11 +6,12 @@ use crate::{ }; use entity::prelude::*; use futures::TryStreamExt; +use parking_lot::Mutex; use sea_orm::DatabaseConnection; use serde_json::to_vec_pretty; use std::sync::Arc; use teloxide::{adaptors::Throttle, prelude::*, types::InputFile}; -use tokio::{sync::Mutex, task::spawn_blocking}; +use tokio::task::spawn_blocking; /// Decryptes the account on a worker thread and adds it to the accounts vector #[inline] @@ -21,7 +22,7 @@ async fn decrypt_account( ) -> crate::Result<()> { let account = spawn_blocking(move || DecryptedAccount::from_account(account, &master_pass)).await??; - accounts.lock().await.push(account); + accounts.lock().push(account); Ok(()) } diff --git a/src/commands/import.rs b/src/commands/import.rs index 0650a1f..e386f63 100644 --- a/src/commands/import.rs +++ b/src/commands/import.rs @@ -6,10 +6,11 @@ use crate::{ }; use futures::{stream, StreamExt}; use itertools::Itertools; +use parking_lot::Mutex; use sea_orm::prelude::*; use std::sync::Arc; use teloxide::{adaptors::Throttle, prelude::*}; -use tokio::{sync::Mutex, task::spawn_blocking}; +use tokio::task::spawn_blocking; /// Ecryptes the account and adds it to the database /// If any of these steps fail, the account name will be added to the failed vector @@ -22,16 +23,16 @@ async fn encrypt_account( failed: &Mutex<&mut Vec>, ) { if !account.validate() { - failed.lock().await.push(account.name); + failed.lock().push(account.name); return; } let name = account.name.clone(); match spawn_blocking(move || account.into_account(user_id, &master_pass)).await { Ok(Ok(account)) => match account.insert(db).await { Ok(_) => (), - Err(_) => failed.lock().await.push(name), + Err(_) => failed.lock().push(name), }, - _ => failed.lock().await.push(name), + _ => failed.lock().push(name), } }