fix: must check logic
This commit is contained in:
parent
fe2b11ed13
commit
ca40009f1a
@ -7,7 +7,7 @@ use std::io::{stdin, stdout};
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::time::{Duration, SystemTime};
|
use std::time::{Duration, SystemTime};
|
||||||
use tokio::fs;
|
use tokio::fs;
|
||||||
use tracing::{debug, error, info, instrument};
|
use tracing::{debug, error, info, instrument, trace};
|
||||||
|
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
@ -119,13 +119,15 @@ async fn fetch(
|
|||||||
let certs = read_dir(&cert_dir).await?;
|
let certs = read_dir(&cert_dir).await?;
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let threshold_exp = min_delta.and_then(|min_delta| {
|
let threshold_exp = min_delta.and_then(|min_delta| {
|
||||||
SystemTime::now().checked_sub(Duration::from_secs(60 * 60 * 24 * min_delta as u64))
|
SystemTime::now().checked_add(Duration::from_secs(60 * 60 * 24 * min_delta as u64))
|
||||||
});
|
});
|
||||||
let updates = certs
|
let updates = certs
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|cert| {
|
.filter(|cert| {
|
||||||
let exp = cert.valid_before_time();
|
let exp = cert.valid_before_time();
|
||||||
threshold_exp.as_ref().map(|th| &exp < th).unwrap_or(true)
|
let must_check = threshold_exp.as_ref().map(|th| &exp < th);
|
||||||
|
trace!(?cert, ?must_check, "filter");
|
||||||
|
must_check.unwrap_or(true)
|
||||||
})
|
})
|
||||||
.map(|cert| {
|
.map(|cert| {
|
||||||
let path = GetCert {
|
let path = GetCert {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user