clippy and fmt

This commit is contained in:
xenofem 2022-05-24 16:52:00 -04:00
parent 8497b4137d
commit 62e6d64253
3 changed files with 41 additions and 41 deletions

View file

@ -16,8 +16,8 @@ use inotify::{Inotify, WatchMask};
use log::trace;
use pin_project_lite::pin_project;
use serde::{de, Deserialize, Deserializer};
use time::OffsetDateTime;
use std::{os::unix::fs::MetadataExt, time::SystemTime};
use time::OffsetDateTime;
use actix_web::{
body::{self, BoxBody, SizedStream},
@ -64,7 +64,9 @@ impl<'de> de::Visitor<'de> for SelectionVisitor {
}
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where E: de::Error {
where
E: de::Error,
{
if v == "all" {
Ok(DownloadSelection::All)
} else if let Ok(n) = v.parse::<usize>() {
@ -76,9 +78,7 @@ impl<'de> de::Visitor<'de> for SelectionVisitor {
}
impl<'de> Deserialize<'de> for DownloadSelection {
fn deserialize<D: Deserializer<'de>>(
de: D
) -> Result<DownloadSelection, D::Error> {
fn deserialize<D: Deserializer<'de>>(de: D) -> Result<DownloadSelection, D::Error> {
de.deserialize_any(SelectionVisitor)
}
}
@ -122,8 +122,10 @@ impl DownloadingFile {
}
fn baseline_offset(&self) -> u64 {
if let (DownloadSelection::One(n), Some(files)) = (self.selection, self.info.contents.as_ref()) {
crate::zip::file_data_offset(&files, n)
if let (DownloadSelection::One(n), Some(files)) =
(self.selection, self.info.contents.as_ref())
{
crate::zip::file_data_offset(files, n)
} else {
0
}
@ -184,12 +186,7 @@ impl DownloadingFile {
res.insert_header((
header::CONTENT_RANGE,
format!(
"bytes {}-{}/{}",
offset,
offset + length - 1,
total_size,
),
format!("bytes {}-{}/{}", offset, offset + length - 1, total_size,),
));
} else {
res.insert_header((header::CONTENT_RANGE, format!("bytes */{}", length)));
@ -209,7 +206,12 @@ impl DownloadingFile {
.map_into_boxed_body();
}
let reader = new_live_reader(length, self.baseline_offset() + offset, self.file, self.storage_path);
let reader = new_live_reader(
length,
self.baseline_offset() + offset,
self.file,
self.storage_path,
);
if offset != 0 || length != total_size {
res.status(StatusCode::PARTIAL_CONTENT);