refactor: removes clippy warnings (#601)
parent
f8b69f4df8
commit
459a4d4f4a
|
@ -297,15 +297,14 @@ impl AccessPerm {
|
|||
|
||||
pub fn www_authenticate(res: &mut Response, args: &Args) -> Result<()> {
|
||||
if args.auth.use_hashed_password {
|
||||
let basic = HeaderValue::from_str(&format!("Basic realm=\"{}\"", REALM))?;
|
||||
let basic = HeaderValue::from_str(&format!("Basic realm=\"{REALM}\""))?;
|
||||
res.headers_mut().insert(WWW_AUTHENTICATE, basic);
|
||||
} else {
|
||||
let nonce = create_nonce()?;
|
||||
let digest = HeaderValue::from_str(&format!(
|
||||
"Digest realm=\"{}\", nonce=\"{}\", qop=\"auth\"",
|
||||
REALM, nonce
|
||||
"Digest realm=\"{REALM}\", nonce=\"{nonce}\", qop=\"auth\""
|
||||
))?;
|
||||
let basic = HeaderValue::from_str(&format!("Basic realm=\"{}\"", REALM))?;
|
||||
let basic = HeaderValue::from_str(&format!("Basic realm=\"{REALM}\""))?;
|
||||
res.headers_mut().append(WWW_AUTHENTICATE, digest);
|
||||
res.headers_mut().append(WWW_AUTHENTICATE, basic);
|
||||
}
|
||||
|
@ -367,7 +366,7 @@ pub fn check_auth(
|
|||
}
|
||||
|
||||
let mut h = Context::new();
|
||||
h.consume(format!("{}:{}:{}", auth_user, REALM, auth_pass).as_bytes());
|
||||
h.consume(format!("{auth_user}:{REALM}:{auth_pass}").as_bytes());
|
||||
let auth_pass = format!("{:x}", h.compute());
|
||||
|
||||
let mut ha = Context::new();
|
||||
|
|
|
@ -64,8 +64,8 @@ impl HttpLogger {
|
|||
}
|
||||
}
|
||||
match err {
|
||||
Some(err) => error!("{} {}", output, err),
|
||||
None => info!("{}", output),
|
||||
Some(err) => error!("{output} {err}"),
|
||||
None => info!("{output}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ async fn main() -> Result<()> {
|
|||
ret = join_all(handles) => {
|
||||
for r in ret {
|
||||
if let Err(e) = r {
|
||||
error!("{}", e);
|
||||
error!("{e}");
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -154,7 +154,7 @@ fn serve(args: Args, running: Arc<AtomicBool>) -> Result<Vec<JoinHandle<()>>> {
|
|||
path.into()
|
||||
};
|
||||
let listener = tokio::net::UnixListener::bind(socket_path)
|
||||
.with_context(|| format!("Failed to bind `{}`", path))?;
|
||||
.with_context(|| format!("Failed to bind `{path}`"))?;
|
||||
let handle = tokio::spawn(async move {
|
||||
loop {
|
||||
let Ok((stream, _addr)) = listener.accept().await else {
|
||||
|
|
|
@ -502,7 +502,7 @@ impl Server {
|
|||
};
|
||||
let stream = IncomingStream::new(req.into_body());
|
||||
|
||||
let body_with_io_error = stream.map_err(|err| io::Error::new(io::ErrorKind::Other, err));
|
||||
let body_with_io_error = stream.map_err(io::Error::other);
|
||||
let body_reader = StreamReader::new(body_with_io_error);
|
||||
|
||||
pin_mut!(body_reader);
|
||||
|
@ -628,7 +628,7 @@ impl Server {
|
|||
) -> Result<()> {
|
||||
let (mut writer, reader) = tokio::io::duplex(BUF_SIZE);
|
||||
let filename = try_get_file_name(path)?;
|
||||
set_content_disposition(res, false, &format!("{}.zip", filename))?;
|
||||
set_content_disposition(res, false, &format!("{filename}.zip"))?;
|
||||
res.headers_mut()
|
||||
.insert("content-type", HeaderValue::from_static("application/zip"));
|
||||
if head_only {
|
||||
|
@ -855,7 +855,7 @@ impl Server {
|
|||
file.seek(SeekFrom::Start(start)).await?;
|
||||
let range_size = end - start + 1;
|
||||
*res.status_mut() = StatusCode::PARTIAL_CONTENT;
|
||||
let content_range = format!("bytes {}-{}/{}", start, end, size);
|
||||
let content_range = format!("bytes {start}-{end}/{size}");
|
||||
res.headers_mut()
|
||||
.insert(CONTENT_RANGE, content_range.parse()?);
|
||||
res.headers_mut()
|
||||
|
@ -879,7 +879,7 @@ impl Server {
|
|||
for (start, end) in ranges {
|
||||
file.seek(SeekFrom::Start(start)).await?;
|
||||
let range_size = end - start + 1;
|
||||
let content_range = format!("bytes {}-{}/{}", start, end, size);
|
||||
let content_range = format!("bytes {start}-{end}/{size}");
|
||||
let part_header = format!(
|
||||
"--{boundary}\r\nContent-Type: {content_type}\r\nContent-Range: {content_range}\r\n\r\n",
|
||||
);
|
||||
|
@ -1704,7 +1704,7 @@ fn set_content_disposition(res: &mut Response, inline: bool, filename: &str) ->
|
|||
})
|
||||
.collect();
|
||||
let value = if filename.is_ascii() {
|
||||
HeaderValue::from_str(&format!("{kind}; filename=\"{}\"", filename,))?
|
||||
HeaderValue::from_str(&format!("{kind}; filename=\"{filename}\"",))?
|
||||
} else {
|
||||
HeaderValue::from_str(&format!(
|
||||
"{kind}; filename=\"{}\"; filename*=UTF-8''{}",
|
||||
|
@ -1799,7 +1799,7 @@ async fn sha256_file(path: &Path) -> Result<String> {
|
|||
}
|
||||
|
||||
let result = hasher.finalize();
|
||||
Ok(format!("{:x}", result))
|
||||
Ok(format!("{result:x}"))
|
||||
}
|
||||
|
||||
fn has_query_flag(query_params: &HashMap<String, String>, name: &str) -> bool {
|
||||
|
|
|
@ -49,7 +49,7 @@ fn same_etag(etag: &str) -> String {
|
|||
}
|
||||
|
||||
fn different_etag(etag: &str) -> String {
|
||||
format!("{}1234", etag)
|
||||
format!("{etag}1234")
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
|
|
|
@ -41,7 +41,7 @@ fn get_file_range_invalid(server: TestServer) -> Result<(), Error> {
|
|||
}
|
||||
|
||||
fn parse_multipart_body<'a>(body: &'a str, boundary: &str) -> Vec<(HeaderMap, &'a str)> {
|
||||
body.split(&format!("--{}", boundary))
|
||||
body.split(&format!("--{boundary}"))
|
||||
.filter(|part| !part.is_empty() && *part != "--\r\n")
|
||||
.map(|part| {
|
||||
let (head, body) = part.trim_ascii().split_once("\r\n\r\n").unwrap();
|
||||
|
|
Loading…
Reference in New Issue