From c4b0f31dbfdd6c63195043f35382512ba4128e81 Mon Sep 17 00:00:00 2001 From: p11 Date: Thu, 19 Sep 2024 14:22:42 +0200 Subject: [PATCH] Use PathBuf.clone instead of to_path_buf --- src/main.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0121a37..1a05e1e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -276,8 +276,8 @@ fn handle_connection( relative_path = path; } - let mut pk_path = path.to_path_buf(); - let mut data_path = path.to_path_buf(); + let mut pk_path = path.clone(); + let mut data_path = path.clone(); let (pki_path, audio_path, start_level, relative_path, partial) = if relative_path.is_empty() { if access == Access::Full { @@ -290,8 +290,8 @@ fn handle_connection( (None, None, 0, String::new(), None) } else { - let mut pki_path = path.to_path_buf(); - let mut audio_path = path.to_path_buf(); + let mut pki_path = path.clone(); + let mut audio_path = path.clone(); let path = percent_decode_str(relative_path).decode_utf8_lossy(); if path.contains('_') { @@ -321,13 +321,12 @@ fn handle_connection( let file_paths = DocumentPaths { pk: &pk_path, - pki: pki_path.as_ref().map(|path| path.as_ref()), - audio: audio_path.as_ref().map(|path| path.as_ref()), + pki: pki_path.as_ref().map(PathBuf::as_ref), + audio: audio_path.as_ref().map(PathBuf::as_ref), data: &data_path, }; if let Some((_, ending)) = relative_path.rsplit_once('.') { - let path = path.to_path_buf(); let ending = ending.to_lowercase(); match ending.as_ref() { "jpg" => reply_binary(stream, &relative_path, "image", "jpeg", path), @@ -370,8 +369,6 @@ fn handle_connection( return; }; - let path = path.to_path_buf(); - handle_relative_connection( info, stream,