Use PathBuf.clone instead of to_path_buf

This commit is contained in:
p11 2024-09-19 14:22:42 +02:00
parent c4e231c9e0
commit c4b0f31dbf

View File

@ -276,8 +276,8 @@ fn handle_connection(
relative_path = path; relative_path = path;
} }
let mut pk_path = path.to_path_buf(); let mut pk_path = path.clone();
let mut data_path = path.to_path_buf(); let mut data_path = path.clone();
let (pki_path, audio_path, start_level, relative_path, partial) = if relative_path.is_empty() { let (pki_path, audio_path, start_level, relative_path, partial) = if relative_path.is_empty() {
if access == Access::Full { if access == Access::Full {
@ -290,8 +290,8 @@ fn handle_connection(
(None, None, 0, String::new(), None) (None, None, 0, String::new(), None)
} else { } else {
let mut pki_path = path.to_path_buf(); let mut pki_path = path.clone();
let mut audio_path = path.to_path_buf(); let mut audio_path = path.clone();
let path = percent_decode_str(relative_path).decode_utf8_lossy(); let path = percent_decode_str(relative_path).decode_utf8_lossy();
if path.contains('_') { if path.contains('_') {
@ -321,13 +321,12 @@ fn handle_connection(
let file_paths = DocumentPaths { let file_paths = DocumentPaths {
pk: &pk_path, pk: &pk_path,
pki: pki_path.as_ref().map(|path| path.as_ref()), pki: pki_path.as_ref().map(PathBuf::as_ref),
audio: audio_path.as_ref().map(|path| path.as_ref()), audio: audio_path.as_ref().map(PathBuf::as_ref),
data: &data_path, data: &data_path,
}; };
if let Some((_, ending)) = relative_path.rsplit_once('.') { if let Some((_, ending)) = relative_path.rsplit_once('.') {
let path = path.to_path_buf();
let ending = ending.to_lowercase(); let ending = ending.to_lowercase();
match ending.as_ref() { match ending.as_ref() {
"jpg" => reply_binary(stream, &relative_path, "image", "jpeg", path), "jpg" => reply_binary(stream, &relative_path, "image", "jpeg", path),
@ -370,8 +369,6 @@ fn handle_connection(
return; return;
}; };
let path = path.to_path_buf();
handle_relative_connection( handle_relative_connection(
info, info,
stream, stream,