diff --git a/src/bitwarden.rs b/src/bitwarden.rs index d7ab098..1df1d21 100644 --- a/src/bitwarden.rs +++ b/src/bitwarden.rs @@ -5,8 +5,8 @@ use tokio::process::Command; use crate::{config::PunlockConfigurationEntry, email::Email}; pub struct Bitwarden { - email: Email, - session: S, + pub email: Email, + pub session: S, } impl Bitwarden<()> { @@ -104,7 +104,10 @@ impl Bitwarden { let secret = match result.as_string() { Some(s) => s.to_owned(), - None => anyhow::bail!("invalid item"), + None => { + tracing::error!(?data, ?expr, "find secret"); + anyhow::bail!("invalid item") + } }; Ok(secret) diff --git a/src/store.rs b/src/store.rs index b25e87f..fe54042 100644 --- a/src/store.rs +++ b/src/store.rs @@ -1,6 +1,11 @@ -use std::{os::unix::fs::PermissionsExt, path::PathBuf, sync::Arc}; +use std::{ + os::unix::fs::PermissionsExt, + path::PathBuf, + process::{Command, Stdio}, + sync::Arc, +}; -use futures::{StreamExt, stream::FuturesUnordered}; +use futures::{stream::FuturesUnordered, StreamExt, TryFutureExt}; use tokio::io::AsyncWriteExt; use crate::{ @@ -52,6 +57,12 @@ impl UnixSecretStore { pub async fn write_secrets(&self, entries: &[PunlockConfigurationEntry]) -> anyhow::Result<()> { let mut tasks = FuturesUnordered::new(); + Command::new("bw") + .args(["sync", "--session", &self.bitwarden.session]) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .inspect_err(|error| tracing::error!(?error, "spawn get"))?; for entry in entries.iter() { let root = self.root_path.clone(); @@ -116,6 +127,7 @@ impl UnixSecretStore { std::os::windows::fs::symlink_file(&src, &dst)?; Ok(()) }) + .inspect_err(|error| tracing::error!(src = ?path, dst = ?link_path, ?error, "symlink failed")) .await .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))??;