mirror of
https://github.com/Kruhlmann/punlock.git
synced 2025-10-27 22:23:34 +00:00
Improve debugging
This commit is contained in:
@@ -5,8 +5,8 @@ use tokio::process::Command;
|
||||
use crate::{config::PunlockConfigurationEntry, email::Email};
|
||||
|
||||
pub struct Bitwarden<S> {
|
||||
email: Email,
|
||||
session: S,
|
||||
pub email: Email,
|
||||
pub session: S,
|
||||
}
|
||||
|
||||
impl Bitwarden<()> {
|
||||
@@ -104,7 +104,10 @@ impl Bitwarden<String> {
|
||||
|
||||
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)
|
||||
|
||||
16
src/store.rs
16
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))??;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user