diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..f3aea91 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,9 @@ +#!/bin/bash + +STAGED_FILES=$(git diff --cached --name-only) + +cargo fmt || exit 1 + +echo "$STAGED_FILES" | xargs git add + +exit 0 diff --git a/src/utils/keyring.rs b/src/utils/keyring.rs index f01c5e3..b1515b8 100644 --- a/src/utils/keyring.rs +++ b/src/utils/keyring.rs @@ -58,21 +58,26 @@ pub fn get_password(fingerprint: &str) -> anyhow::Result { } } - if settings.get_keyring_expiry_days().is_some() { - let expiry = fs::read(get_session_path(fingerprint)); - let expiry = match expiry { - Ok(e) => e, - Err(_) => { - clear_password(fingerprint)?; - bail!("No session found"); - } - }; + match settings.get_keyring_expiry() { + KeyringExpiry::Days(_) => { + let expiry = fs::read(get_session_path(fingerprint)); + let expiry = match expiry { + Ok(e) => e, + Err(_) => { + clear_password(fingerprint)?; + bail!("No session found"); + } + }; - let expiry: SystemTime = bincode::deserialize(&expiry)?; + let expiry: SystemTime = bincode::deserialize(&expiry)?; - if expiry < SystemTime::now() { - clear_password(fingerprint)?; - bail!("Session expired"); + if expiry < SystemTime::now() { + clear_password(fingerprint)?; + bail!("Session expired"); + } + } + _ => { + println!("No keyring expiry set"); } }