Address a bunch of lint
This commit is contained in:
parent
3dfd2d48b3
commit
714e73aeb1
@ -3,6 +3,7 @@ use std::{
|
|||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fs::File,
|
fs::File,
|
||||||
hash::{DefaultHasher, Hash, Hasher},
|
hash::{DefaultHasher, Hash, Hasher},
|
||||||
|
time::Instant,
|
||||||
};
|
};
|
||||||
|
|
||||||
use async_graphql::{
|
use async_graphql::{
|
||||||
@ -13,7 +14,6 @@ use log::{error, info, warn};
|
|||||||
use mailparse::{parse_mail, MailHeader, MailHeaderMap, ParsedMail};
|
use mailparse::{parse_mail, MailHeader, MailHeaderMap, ParsedMail};
|
||||||
use memmap::MmapOptions;
|
use memmap::MmapOptions;
|
||||||
use notmuch::Notmuch;
|
use notmuch::Notmuch;
|
||||||
use rocket::time::Instant;
|
|
||||||
|
|
||||||
use crate::{error::ServerError, linkify_html, sanitize_html};
|
use crate::{error::ServerError, linkify_html, sanitize_html};
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ impl QueryRoot {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
info!("Fetching tags took {}", now.elapsed());
|
info!("Fetching tags took {} seconds", now.elapsed().as_secs_f32());
|
||||||
Ok(tags)
|
Ok(tags)
|
||||||
}
|
}
|
||||||
async fn thread<'ctx>(&self, ctx: &Context<'ctx>, thread_id: String) -> Result<Thread, Error> {
|
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
|
let headers = m
|
||||||
.headers
|
.headers
|
||||||
@ -527,11 +526,12 @@ fn extract_body(m: &ParsedMail, id: &str) -> Result<Body, Error> {
|
|||||||
|
|
||||||
fn extract_unhandled(m: &ParsedMail) -> Result<Body, Error> {
|
fn extract_unhandled(m: &ParsedMail) -> Result<Body, Error> {
|
||||||
let msg = format!(
|
let msg = format!(
|
||||||
"Unhandled body content type:\n{}",
|
"Unhandled body content type:\n{}\n{}",
|
||||||
render_content_type_tree(m)
|
render_content_type_tree(m),
|
||||||
|
m.get_body()?,
|
||||||
);
|
);
|
||||||
Ok(Body::UnhandledContentType(UnhandledContentType {
|
Ok(Body::UnhandledContentType(UnhandledContentType {
|
||||||
text: m.get_body()?,
|
text: msg,
|
||||||
content_tree: render_content_type_tree(m),
|
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}");
|
info!("get_attachment_filename {header_value}");
|
||||||
// Strip last "
|
// Strip last "
|
||||||
let v = &header_value[..header_value.len() - 1];
|
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(v) = headers.get_first_value("Content-Type") {
|
||||||
if let Some(idx) = v.find(';') {
|
if let Some(idx) = v.find(';') {
|
||||||
return Some(v[..idx].to_string());
|
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 file = File::open(&path)?;
|
||||||
let mmap = unsafe { MmapOptions::new().map(&file)? };
|
let mmap = unsafe { MmapOptions::new().map(&file)? };
|
||||||
let m = parse_mail(&mmap)?;
|
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));
|
info!("{cid} {:?}", get_content_id(&sp.headers));
|
||||||
if let Some(h_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];
|
let h_cid = &h_cid[1..h_cid.len() - 1];
|
||||||
|
|||||||
@ -4,7 +4,7 @@ pub mod nm;
|
|||||||
|
|
||||||
use css_inline::{CSSInliner, InlineError, InlineOptions};
|
use css_inline::{CSSInliner, InlineError, InlineOptions};
|
||||||
use linkify::{LinkFinder, LinkKind};
|
use linkify::{LinkFinder, LinkKind};
|
||||||
use log::{error, info};
|
use log::error;
|
||||||
use lol_html::{element, errors::RewritingError, rewrite_str, RewriteStrSettings};
|
use lol_html::{element, errors::RewritingError, rewrite_str, RewriteStrSettings};
|
||||||
use maplit::{hashmap, hashset};
|
use maplit::{hashmap, hashset};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user