fix on filter
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
Paul 2023-11-04 12:42:07 +01:00
parent b82551c562
commit 4c697c2e0c
2 changed files with 5 additions and 4 deletions

View File

@ -89,7 +89,7 @@ impl Display for IpData {
} }
pub fn filter( pub fn filter(
lines: Box<dyn Read>, reader: Box<dyn Read>,
iplist: &mut Vec<IpData>, iplist: &mut Vec<IpData>,
trustnets: &Vec<IpNet>, trustnets: &Vec<IpNet>,
regex: &Regex, regex: &Regex,
@ -98,7 +98,8 @@ pub fn filter(
) -> isize { ) -> isize {
let mut ips = 0; let mut ips = 0;
let hostname = gethostname(true); let hostname = gethostname(true);
for line in BufReader::new(lines).lines() { let lines = BufReader::new(reader).lines();
for line in lines.into_iter() {
if let Ok(l) = line { if let Ok(l) = line {
if regex.is_match(l.as_str()) { if regex.is_match(l.as_str()) {
let s_ipaddr: String; let s_ipaddr: String;

View File

@ -181,12 +181,12 @@ async fn watchfiles(inoarc: Arc<RwLock<Inotify>>) -> Receiver<FileEvent> {
async fn get_last_file_size(w: &mut HashMap<String, u64>, path: &str) -> (u64, bool) { async fn get_last_file_size(w: &mut HashMap<String, u64>, path: &str) -> (u64, bool) {
let currentlen = match std::fs::metadata(&path.to_string()) { let currentlen = match std::fs::metadata(&path.to_string()) {
Ok(u) => u.len().clone(), Ok(u) => u.len(),
Err(_) => 0u64, Err(_) => 0u64,
}; };
let lastlen = match w.insert(path.to_string(), currentlen) { let lastlen = match w.insert(path.to_string(), currentlen) {
Some(u) => u, Some(u) => u,
None => 0u64, None => currentlen,
}; };
(lastlen, lastlen != currentlen) (lastlen, lastlen != currentlen)
} }