Browse Source

Cleanup the code

pull/31/head
Rodolphe Breard 4 years ago
parent
commit
5a06631e05
  1. 2
      acmed/src/endpoint.rs
  2. 2
      acmed/src/http.rs
  3. 7
      acmed/src/main_event_loop.rs
  4. 2
      acmed/src/storage.rs

2
acmed/src/endpoint.rs

@ -130,7 +130,7 @@ fn is_duration_chr(c: char) -> bool {
fn get_multiplicator(input: &str) -> IResult<&str, u64> { fn get_multiplicator(input: &str) -> IResult<&str, u64> {
let (input, nb) = take_while_m_n(1, 1, is_duration_chr)(input)?; let (input, nb) = take_while_m_n(1, 1, is_duration_chr)(input)?;
let mult = match nb.chars().nth(0) {
let mult = match nb.chars().next() {
Some('s') => 1, Some('s') => 1,
Some('m') => 60, Some('m') => 60,
Some('h') => 3_600, Some('h') => 3_600,

2
acmed/src/http.rs

@ -34,7 +34,7 @@ fn update_nonce(endpoint: &mut Endpoint, response: &Response) -> Result<(), Erro
let msg = format!("{}: invalid nonce.", &nonce); let msg = format!("{}: invalid nonce.", &nonce);
return Err(msg.into()); return Err(msg.into());
} }
endpoint.nonce = Some(nonce.to_string());
endpoint.nonce = Some(nonce);
} }
Ok(()) Ok(())
} }

7
acmed/src/main_event_loop.rs

@ -64,10 +64,9 @@ impl MainEventLoop {
env: crt.env.to_owned(), env: crt.env.to_owned(),
id: i + 1, id: i + 1,
}; };
if !endpoints.contains_key(&endpoint_name) {
let ep = Arc::new(RwLock::new(endpoint));
endpoints.insert(endpoint_name, ep);
}
endpoints
.entry(endpoint_name)
.or_insert_with(|| Arc::new(RwLock::new(endpoint)));
init_account(&cert)?; init_account(&cert)?;
certs.push(cert); certs.push(cert);
} }

2
acmed/src/storage.rs

@ -135,7 +135,7 @@ fn write_file(cert: &Certificate, file_type: FileType, data: &[u8]) -> Result<()
let mut hook_data = FileStorageHookData { let mut hook_data = FileStorageHookData {
file_name, file_name,
file_directory, file_directory,
file_path: path.to_path_buf(),
file_path: path.to_owned(),
env: HashMap::new(), env: HashMap::new(),
}; };
hook_data.set_env(&cert.env); hook_data.set_env(&cert.env);

Loading…
Cancel
Save