aboutsummaryrefslogtreecommitdiffstats
path: root/src/dirs.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2020-05-03 04:07:03 -0400
committerJesse Luehrs <doy@tozt.net>2020-05-03 04:09:34 -0400
commitdbdd8a78951f8a44630abcceb7b13d0d823ee074 (patch)
tree64c69f16279876c71ba22a55ef6dd255289aaaef /src/dirs.rs
parent6ebf7d55e4c553870306a70092cfb677c17429b9 (diff)
downloadrbw-dbdd8a78951f8a44630abcceb7b13d0d823ee074.tar.gz
rbw-dbdd8a78951f8a44630abcceb7b13d0d823ee074.zip
allow storing password databases from different servers
this should allow easy switching of servers by just `rbw config set base_url`
Diffstat (limited to 'src/dirs.rs')
-rw-r--r--src/dirs.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/dirs.rs b/src/dirs.rs
index 5dd2c35..53a433e 100644
--- a/src/dirs.rs
+++ b/src/dirs.rs
@@ -17,8 +17,13 @@ pub fn config_file() -> std::path::PathBuf {
config_dir().join("config.json")
}
-pub fn db_file(email: &str) -> std::path::PathBuf {
- cache_dir().join(format!("{}.json", email))
+const INVALID_PATH: &percent_encoding::AsciiSet =
+ &percent_encoding::CONTROLS.add(b'/').add(b'%').add(b':');
+pub fn db_file(server: &str, email: &str) -> std::path::PathBuf {
+ let server =
+ percent_encoding::percent_encode(server.as_bytes(), INVALID_PATH)
+ .to_string();
+ cache_dir().join(format!("{}:{}.json", server, email))
}
pub fn pid_file() -> std::path::PathBuf {