From 4e619d0ebc08d201d71fc50de08121c2867011d2 Mon Sep 17 00:00:00 2001 From: Rushmore75 Date: Thu, 17 Apr 2025 09:36:13 -0600 Subject: [PATCH] logging cleanup --- src/filesystem.rs | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/src/filesystem.rs b/src/filesystem.rs index 64a96cb..2d24d65 100644 --- a/src/filesystem.rs +++ b/src/filesystem.rs @@ -1,8 +1,8 @@ -use std::{ffi::OsStr, io::ErrorKind, path::PathBuf}; +use std::{io::ErrorKind, path::PathBuf}; use reqwest::header::HeaderValue; use tokio::fs; -use tracing::{error, trace}; +use tracing::{error, trace, warn}; use url::Url; 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"); } } + } else { + warn!("Header: {:?} couldn't be parsed into a string!", content_type); } trace!("Final path for {} is: {:?}", url, url_path); @@ -55,29 +57,10 @@ pub async fn init(filename: &PathBuf) -> Option { error!("Couldn't get file's parents: {:?}", &filename); } } 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 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, - } -}