diff options
| author | KunoiSayami <[email protected]> | 2021-05-07 02:06:52 +0800 |
|---|---|---|
| committer | KunoiSayami <[email protected]> | 2021-05-07 02:06:52 +0800 |
| commit | e13d73f9c501d7340712feb7b666775fc55b75b3 (patch) | |
| tree | 362671916f47f3e278ff1031a4a58692a573e290 /src/datastructures.rs | |
| parent | c86aab7847dd62492318e4c0d0a733e5a86a305b (diff) | |
feat: Make redis key more shorter
Diffstat (limited to 'src/datastructures.rs')
| -rw-r--r-- | src/datastructures.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/datastructures.rs b/src/datastructures.rs index d253fcb..12e23a2 100644 --- a/src/datastructures.rs +++ b/src/datastructures.rs @@ -24,15 +24,14 @@ use url::form_urlencoded; use std::borrow::Cow; use std::path::Path; use std::fs::read_to_string; -use std::convert::TryFrom; const DEFAULT_CONFIG_LOCATION: &str = "/etc/cgitrc"; -const DEFAULT_COOKIE_TTL: usize = 1200; +const DEFAULT_COOKIE_TTL: u64 = 1200; const DEFAULT_DATABASE_LOCATION: &str = "/etc/cgit/auth.db"; #[derive(Debug, Clone)] pub struct Config { - pub cookie_ttl: usize, + pub cookie_ttl: u64, database: String, } @@ -52,7 +51,7 @@ impl Config { pub fn load_from_path<P: AsRef<Path>>(path: P) -> Self { let file = read_to_string(path).unwrap_or_default(); - let mut cookie_ttl: usize = DEFAULT_COOKIE_TTL; + let mut cookie_ttl: u64 = DEFAULT_COOKIE_TTL; let mut database: &str = "/etc/cgit/auth.db"; for line in file.lines() { @@ -68,7 +67,7 @@ impl Config { }; let key_name = key.split_once("auth-").unwrap().1; match key_name { - "cookie-ttl" => cookie_ttl = usize::try_from(value).unwrap_or(DEFAULT_COOKIE_TTL), + "cookie-ttl" => cookie_ttl = value.parse().unwrap_or(DEFAULT_COOKIE_TTL), "database" => database = value, _ => {} } |
