Skip to content

Commit

Permalink
Store public key config in XDG_DATA_HOME
Browse files Browse the repository at this point in the history
It’s not config—it’s related state related to this host’s private key and thus is *shared data*
  • Loading branch information
mxcl committed Dec 8, 2024
1 parent 0dc56c4 commit 7bb160b
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions bpb/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,25 @@ struct PublicKey {
}

fn keys_file() -> std::path::PathBuf {
if let Ok(config_home) = std::env::var("XDG_CONFIG_HOME") {
std::path::PathBuf::from(config_home).join("pkgx/bpb.toml")
} else {
std::path::PathBuf::from(std::env::var("HOME").unwrap()).join(".config/pkgx/bpb.toml")
}
// for archaic reasons we first check the config path
// however this is an error, we shouldn’t store this as config seeing as it is
// tied to the private key which is likely a host setting and should not thus be
// synced between machines

let config_path = if let Ok(config_home) = std::env::var("XDG_CONFIG_HOME") {
std::path::PathBuf::from(config_home).join("pkgx/bpb.toml")
} else {
std::path::PathBuf::from(std::env::var("HOME").unwrap()).join(".config/pkgx/bpb.toml")
};

if config_path.exists() {
config_path
} else {
let data_path = if let Ok(data_home) = std::env::var("XDG_DATA_HOME") {
std::path::PathBuf::from(data_home).join("pkgx/bpb.toml")
} else {
std::path::PathBuf::from(std::env::var("HOME").unwrap()).join(".local/share/pkgx/bpb.toml")
};
data_path

Check failure on line 84 in bpb/src/config.rs

View workflow job for this annotation

GitHub Actions / Clippy

returning the result of a `let` binding from a block
}
}

0 comments on commit 7bb160b

Please sign in to comment.