Address a bunch of lint

This commit is contained in:
Bill Thiede 2024-07-05 10:44:37 -07:00
parent 3dfd2d48b3
commit 714e73aeb1
2 changed files with 10 additions and 10 deletions

View File

@ -3,6 +3,7 @@ use std::{
collections::HashMap,
fs::File,
hash::{DefaultHasher, Hash, Hasher},
time::Instant,
};
use async_graphql::{
@ -13,7 +14,6 @@ use log::{error, info, warn};
use mailparse::{parse_mail, MailHeader, MailHeaderMap, ParsedMail};
use memmap::MmapOptions;
use notmuch::Notmuch;
use rocket::time::Instant;
use crate::{error::ServerError, linkify_html, sanitize_html};
@ -298,7 +298,7 @@ impl QueryRoot {
}
})
.collect();
info!("Fetching tags took {}", now.elapsed());
info!("Fetching tags took {} seconds", now.elapsed().as_secs_f32());
Ok(tags)
}
async fn thread<'ctx>(&self, ctx: &Context<'ctx>, thread_id: String) -> Result<Thread, Error> {
@ -390,7 +390,6 @@ impl QueryRoot {
},
})
}
b => b,
};
let headers = m
.headers
@ -527,11 +526,12 @@ fn extract_body(m: &ParsedMail, id: &str) -> Result<Body, Error> {
fn extract_unhandled(m: &ParsedMail) -> Result<Body, Error> {
let msg = format!(
"Unhandled body content type:\n{}",
render_content_type_tree(m)
"Unhandled body content type:\n{}\n{}",
render_content_type_tree(m),
m.get_body()?,
);
Ok(Body::UnhandledContentType(UnhandledContentType {
text: m.get_body()?,
text: msg,
content_tree: render_content_type_tree(m),
}))
}
@ -804,7 +804,7 @@ fn extract_attachment(m: &ParsedMail, id: &str, idx: &[usize]) -> Option<Attachm
});
}
fn get_attachment_filename(header_value: &str) -> &str {
pub fn get_attachment_filename(header_value: &str) -> &str {
info!("get_attachment_filename {header_value}");
// Strip last "
let v = &header_value[..header_value.len() - 1];
@ -815,7 +815,7 @@ fn get_attachment_filename(header_value: &str) -> &str {
}
}
fn get_content_type<'a>(headers: &[MailHeader<'a>]) -> Option<String> {
pub fn get_content_type<'a>(headers: &[MailHeader<'a>]) -> Option<String> {
if let Some(v) = headers.get_first_value("Content-Type") {
if let Some(idx) = v.find(';') {
return Some(v[..idx].to_string());
@ -936,7 +936,7 @@ pub fn cid_attachment_bytes(nm: &Notmuch, id: &str, cid: &str) -> Result<Attachm
let file = File::open(&path)?;
let mmap = unsafe { MmapOptions::new().map(&file)? };
let m = parse_mail(&mmap)?;
if let Some(attachment) = walk_attachments(&m, |sp, cur_idx| {
if let Some(attachment) = walk_attachments(&m, |sp, _cur_idx| {
info!("{cid} {:?}", get_content_id(&sp.headers));
if let Some(h_cid) = get_content_id(&sp.headers) {
let h_cid = &h_cid[1..h_cid.len() - 1];

View File

@ -4,7 +4,7 @@ pub mod nm;
use css_inline::{CSSInliner, InlineError, InlineOptions};
use linkify::{LinkFinder, LinkKind};
use log::{error, info};
use log::error;
use lol_html::{element, errors::RewritingError, rewrite_str, RewriteStrSettings};
use maplit::{hashmap, hashset};
use thiserror::Error;