mirror of
https://github.com/amigan/rustypaste-pretty.git
synced 2024-11-21 11:59:48 -05:00
fix(lints): apply clippy suggestions
This commit is contained in:
parent
3cc40deca0
commit
6f1dcab15a
4 changed files with 6 additions and 11 deletions
|
@ -11,7 +11,7 @@ pub const EXPIRE: &str = "expire";
|
|||
|
||||
/// Parses the expiry date from the [`custom HTTP header`](EXPIRE).
|
||||
pub fn parse_expiry_date(headers: &HeaderMap) -> Result<Option<u128>, ActixError> {
|
||||
if let Some(expire_time) = headers.get(EXPIRE).map(|v| v.to_str().ok()).flatten() {
|
||||
if let Some(expire_time) = headers.get(EXPIRE).and_then(|v| v.to_str().ok()) {
|
||||
let timestamp = util::get_system_time()?;
|
||||
let expire_time =
|
||||
humantime::parse_duration(expire_time).map_err(error::ErrorInternalServerError)?;
|
||||
|
@ -57,8 +57,7 @@ impl ContentDisposition {
|
|||
.parameters
|
||||
.iter()
|
||||
.find(|param| param.is_filename())
|
||||
.map(|param| param.as_filename())
|
||||
.flatten()
|
||||
.and_then(|param| param.as_filename())
|
||||
.filter(|file_name| !file_name.is_empty())
|
||||
.ok_or_else(|| error::ErrorBadRequest("file data not present"))
|
||||
}
|
||||
|
|
|
@ -25,8 +25,7 @@ pub fn get_mime_type(
|
|||
let path = PathBuf::from(&file_name);
|
||||
let mut mime_type = file_extension_to_mime(
|
||||
path.extension()
|
||||
.map(|v| v.to_str())
|
||||
.flatten()
|
||||
.and_then(|v| v.to_str())
|
||||
.unwrap_or_default(),
|
||||
);
|
||||
for matcher in mime_matchers {
|
||||
|
|
|
@ -104,8 +104,7 @@ impl Paste {
|
|||
}
|
||||
let file_name = match PathBuf::from(file_name)
|
||||
.file_name()
|
||||
.map(|v| v.to_str())
|
||||
.flatten()
|
||||
.and_then(|v| v.to_str())
|
||||
{
|
||||
Some("-") => String::from("stdin"),
|
||||
Some(v) => v.to_string(),
|
||||
|
|
|
@ -39,10 +39,8 @@ pub fn glob_match_file(mut path: PathBuf) -> Result<PathBuf, ActixError> {
|
|||
let glob_path = glob_path.map_err(error::ErrorInternalServerError)?;
|
||||
if let Some(extension) = glob_path
|
||||
.extension()
|
||||
.map(|v| v.to_str())
|
||||
.flatten()
|
||||
.map(|v| v.parse().ok())
|
||||
.flatten()
|
||||
.and_then(|v| v.to_str())
|
||||
.and_then(|v| v.parse().ok())
|
||||
{
|
||||
if get_system_time()? < Duration::from_millis(extension) {
|
||||
path = glob_path;
|
||||
|
|
Loading…
Reference in a new issue