logging cleanup
This commit is contained in:
parent
647c4cd324
commit
4e619d0ebc
@ -1,8 +1,8 @@
|
|||||||
use std::{ffi::OsStr, io::ErrorKind, path::PathBuf};
|
use std::{io::ErrorKind, path::PathBuf};
|
||||||
|
|
||||||
use reqwest::header::HeaderValue;
|
use reqwest::header::HeaderValue;
|
||||||
use tokio::fs;
|
use tokio::fs;
|
||||||
use tracing::{error, trace};
|
use tracing::{error, trace, warn};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
pub fn as_path(url: &Url, content_type: &HeaderValue) -> PathBuf {
|
pub fn as_path(url: &Url, content_type: &HeaderValue) -> PathBuf {
|
||||||
@ -26,6 +26,8 @@ pub fn as_path(url: &Url, content_type: &HeaderValue) -> PathBuf {
|
|||||||
url_path = url_path.join("index.html");
|
url_path = url_path.join("index.html");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
warn!("Header: {:?} couldn't be parsed into a string!", content_type);
|
||||||
}
|
}
|
||||||
trace!("Final path for {} is: {:?}", url, url_path);
|
trace!("Final path for {} is: {:?}", url, url_path);
|
||||||
|
|
||||||
@ -55,29 +57,10 @@ pub async fn init(filename: &PathBuf) -> Option<fs::File> {
|
|||||||
error!("Couldn't get file's parents: {:?}", &filename);
|
error!("Couldn't get file's parents: {:?}", &filename);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
error!("File creation: {err} {:?}", filename);
|
error!("File open error: {err} {:?}", filename);
|
||||||
}
|
}
|
||||||
// we don't care about other errors, we can't/shouldn't fix them
|
// we don't care about other errors, we can't/shouldn't fix them
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn valid_file_extension(take: &&OsStr) -> bool {
|
|
||||||
let los = take.to_string_lossy();
|
|
||||||
let all = los.split('.');
|
|
||||||
match all.last() {
|
|
||||||
Some(s) => {
|
|
||||||
// FIXME it's worth noting that the dumb tlds like .zip are in here,
|
|
||||||
// which could cause problems
|
|
||||||
let all_domains = include_str!("tlds-alpha-by-domain.txt");
|
|
||||||
|
|
||||||
// check if it is a domain
|
|
||||||
match all_domains.lines().map(str::to_lowercase).find(|x| x==s.to_lowercase().as_str()) {
|
|
||||||
Some(_) => false,
|
|
||||||
None => true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
None => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user