Skip to content

Commit 7bb160b

Browse files
committed
Store public key config in XDG_DATA_HOME
It’s not config—it’s related state related to this host’s private key and thus is *shared data*
1 parent 0dc56c4 commit 7bb160b

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

bpb/src/config.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,25 @@ struct PublicKey {
6262
}
6363

6464
fn keys_file() -> std::path::PathBuf {
65-
if let Ok(config_home) = std::env::var("XDG_CONFIG_HOME") {
66-
std::path::PathBuf::from(config_home).join("pkgx/bpb.toml")
67-
} else {
68-
std::path::PathBuf::from(std::env::var("HOME").unwrap()).join(".config/pkgx/bpb.toml")
69-
}
65+
// for archaic reasons we first check the config path
66+
// however this is an error, we shouldn’t store this as config seeing as it is
67+
// tied to the private key which is likely a host setting and should not thus be
68+
// synced between machines
69+
70+
let config_path = if let Ok(config_home) = std::env::var("XDG_CONFIG_HOME") {
71+
std::path::PathBuf::from(config_home).join("pkgx/bpb.toml")
72+
} else {
73+
std::path::PathBuf::from(std::env::var("HOME").unwrap()).join(".config/pkgx/bpb.toml")
74+
};
75+
76+
if config_path.exists() {
77+
config_path
78+
} else {
79+
let data_path = if let Ok(data_home) = std::env::var("XDG_DATA_HOME") {
80+
std::path::PathBuf::from(data_home).join("pkgx/bpb.toml")
81+
} else {
82+
std::path::PathBuf::from(std::env::var("HOME").unwrap()).join(".local/share/pkgx/bpb.toml")
83+
};
84+
data_path
85+
}
7086
}

0 commit comments

Comments
 (0)