1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-07 20:24:01 +00:00

Fix and remove some TODOs

This commit is contained in:
Dmitry Yakimenko
2025-10-25 23:14:51 +02:00
parent 129531a320
commit b6fec3b17e
2 changed files with 12 additions and 7 deletions

View File

@@ -6,6 +6,7 @@ use tokio::{
net::windows::named_pipe::{NamedPipeServer, ServerOptions},
sync::mpsc::channel,
task::JoinHandle,
time::{timeout, Duration},
};
use windows::{
core::PCWSTR,
@@ -14,6 +15,8 @@ use windows::{
use crate::abe_config;
const WAIT_FOR_ADMIN_MESSAGE_TIMEOUT_SECS: u64 = 30;
pub fn start_tokio_named_pipe_server<F>(
pipe_name: &'static str,
process_message: F,
@@ -28,7 +31,6 @@ where
// Here we also make use of `first_pipe_instance`, which will ensure that
// there are no other servers up and running already.
let mut server = ServerOptions::new()
// TODO: Try message mode
.first_pipe_instance(true)
.create(pipe_name)?;
@@ -129,11 +131,16 @@ pub async fn decrypt_with_admin_exe(admin_exe: &str, encrypted: &str) -> Result<
debug!("Launching '{}' as ADMINISTRATOR...", admin_exe);
decrypt_with_admin_exe_internal(admin_exe, encrypted);
// TODO: Don't wait forever, but for a reasonable time
debug!("Waiting for message from {}...", admin_exe);
let message = match rx.recv().await {
Some(msg) => msg,
None => return Err(anyhow!("Failed to receive message from admin")),
let message = match timeout(
Duration::from_secs(WAIT_FOR_ADMIN_MESSAGE_TIMEOUT_SECS),
rx.recv(),
)
.await
{
Ok(Some(msg)) => msg,
Ok(None) => return Err(anyhow!("Channel closed without message from {}", admin_exe)),
Err(_) => return Err(anyhow!("Timeout waiting for message from {}", admin_exe)),
};
debug!("Shutting down the pipe server...");

View File

@@ -57,7 +57,6 @@ pub trait InstalledBrowserRetriever {
pub struct DefaultInstalledBrowserRetriever {}
impl InstalledBrowserRetriever for DefaultInstalledBrowserRetriever {
// TODO: Make thus async
fn get_installed_browsers() -> Result<Vec<String>> {
let mut browsers = Vec::with_capacity(SUPPORTED_BROWSER_MAP.len());
@@ -72,7 +71,6 @@ impl InstalledBrowserRetriever for DefaultInstalledBrowserRetriever {
}
}
// TODO: Make thus async
pub fn get_available_profiles(browser_name: &String) -> Result<Vec<ProfileInfo>> {
let (_, local_state) = load_local_state_for_browser(browser_name)?;
Ok(get_profile_info(&local_state))