diff --git a/src/key.rs b/src/key.rs index fab783aba8..35a588339e 100644 --- a/src/key.rs +++ b/src/key.rs @@ -247,7 +247,7 @@ async fn generate_keypair(context: &Context) -> Result { secret: SignedSecretKey::from_slice(&sec_bytes)?, }), Err(sql::Error::Sql(rusqlite::Error::QueryReturnedNoRows)) => { - let start = std::time::Instant::now(); + let start = std::time::SystemTime::now(); let keytype = KeyGenType::from_i32(context.get_config_int(Config::KeyGenType).await) .unwrap_or_default(); info!(context, "Generating keypair with type {}", keytype); @@ -258,7 +258,7 @@ async fn generate_keypair(context: &Context) -> Result { info!( context, "Keypair generated in {:.3}s.", - start.elapsed().as_secs() + start.elapsed().unwrap_or_default().as_secs() ); Ok(keypair) } diff --git a/src/smtp/mod.rs b/src/smtp/mod.rs index 101a12bed2..1296c796c1 100644 --- a/src/smtp/mod.rs +++ b/src/smtp/mod.rs @@ -2,7 +2,7 @@ pub mod send; -use std::time::{Duration, Instant}; +use std::time::{Duration, SystemTime}; use async_smtp::smtp::client::net::*; use async_smtp::*; @@ -55,7 +55,7 @@ pub(crate) struct Smtp { /// Timestamp of last successful send/receive network interaction /// (eg connect or send succeeded). On initialization and disconnect /// it is set to None. - last_success: Option, + last_success: Option, } impl Smtp { @@ -76,7 +76,11 @@ impl Smtp { /// have been successfully used the last 60 seconds pub async fn has_maybe_stale_connection(&self) -> bool { if let Some(last_success) = self.last_success { - Instant::now().duration_since(last_success).as_secs() > 60 + SystemTime::now() + .duration_since(last_success) + .unwrap_or_default() + .as_secs() + > 60 } else { false } @@ -188,7 +192,7 @@ impl Smtp { } self.transport = Some(trans); - self.last_success = Some(Instant::now()); + self.last_success = Some(SystemTime::now()); context.emit_event(Event::SmtpConnected(format!( "SMTP-LOGIN as {} ok", diff --git a/src/smtp/send.rs b/src/smtp/send.rs index 350d705e5b..1948ccf7e6 100644 --- a/src/smtp/send.rs +++ b/src/smtp/send.rs @@ -53,7 +53,7 @@ impl Smtp { "Message len={} was smtp-sent to {}", message_len, recipients_display ))); - self.last_success = Some(std::time::Instant::now()); + self.last_success = Some(std::time::SystemTime::now()); Ok(()) } else {