From a724a964061d26d71aec5db2d5e9f56bfb738a1a Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Fri, 26 Apr 2019 23:18:01 +0200 Subject: [PATCH] rename state_dir to token_dir --- Rocket.toml.dist | 2 +- database/src/stateful_tokens.rs | 16 ++++++++-------- src/web/mod.rs | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Rocket.toml.dist b/Rocket.toml.dist index 68da577..14241ce 100644 --- a/Rocket.toml.dist +++ b/Rocket.toml.dist @@ -4,7 +4,7 @@ port = 8080 template_dir = "dist/templates" assets_dir = "dist/assets" keys_dir = "dist/keys" -state_dir = "dist/hagrid_state" +token_dir = "dist/tokens" tmp_dir = "dist/tmp" [development] diff --git a/database/src/stateful_tokens.rs b/database/src/stateful_tokens.rs index 459cae0..15c27a5 100644 --- a/database/src/stateful_tokens.rs +++ b/database/src/stateful_tokens.rs @@ -7,18 +7,18 @@ use std::str; use Result; pub struct StatefulTokens { - state_dir: PathBuf, + token_dir: PathBuf, } impl StatefulTokens { - pub fn new(state_dir: impl Into) -> Result { - let state_dir = state_dir.into(); - create_dir_all(&state_dir)?; + pub fn new(token_dir: impl Into) -> Result { + let token_dir = token_dir.into(); + create_dir_all(&token_dir)?; info!("Opened stateful token store"); - info!("state_dir: '{}'", state_dir.display()); + info!("token_dir: '{}'", token_dir.display()); - Ok(StatefulTokens { state_dir }) + Ok(StatefulTokens { token_dir }) } pub fn new_token(&self, token_type: &str, payload: &[u8]) -> Result { @@ -29,7 +29,7 @@ impl StatefulTokens { // samples from [a-zA-Z0-9] // 43 chars ~ 256 bit let name: String = rng.sample_iter(&Alphanumeric).take(43).collect(); - let dir = self.state_dir.join(token_type); + let dir = self.token_dir.join(token_type); create_dir_all(&dir)?; let mut fd = File::create(dir.join(&name))?; @@ -39,7 +39,7 @@ impl StatefulTokens { } pub fn pop_token(&self, token_type: &str, token: &str) -> Result { - let path = self.state_dir.join(token_type).join(token); + let path = self.token_dir.join(token_type).join(token); let buf = { let mut fd = File::open(&path)?; let mut buf = Vec::default(); diff --git a/src/web/mod.rs b/src/web/mod.rs index e33a269..2d21f17 100644 --- a/src/web/mod.rs +++ b/src/web/mod.rs @@ -416,8 +416,8 @@ fn configure_hagrid_state(config: &Config) -> Result { } fn configure_stateful_token_service(config: &Config) -> Result { - let state_dir: PathBuf = config.get_str("state_dir")?.into(); - database::StatefulTokens::new(state_dir) + let token_dir: PathBuf = config.get_str("token_dir")?.into(); + database::StatefulTokens::new(token_dir) } fn configure_stateless_token_service(config: &Config) -> Result { @@ -502,7 +502,7 @@ pub mod tests { .to_str().unwrap()) .extra("keys_dir", base_dir.join("keys").to_str().unwrap()) .extra("tmp_dir", base_dir.join("tmp").to_str().unwrap()) - .extra("state_dir", base_dir.join("state").to_str().unwrap()) + .extra("token_dir", base_dir.join("tokens").to_str().unwrap()) .extra("base-URI", BASE_URI) .extra("from", "from") .extra("token_secret", "hagrid")