From 900d9ac4490eda0a257aac5b308a6e2b9fb98dfb Mon Sep 17 00:00:00 2001 From: neri Date: Mon, 23 Jan 2023 11:23:48 +0100 Subject: [PATCH] refactor: construct filepaths more idiomatically --- src/download.rs | 3 +-- src/upload.rs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/download.rs b/src/download.rs index 20ddc56..220e0f8 100644 --- a/src/download.rs +++ b/src/download.rs @@ -37,8 +37,7 @@ pub async fn download( ) -> Result { let id = req.match_info().query("id"); let (file_id, file_name, valid_till, content_type, delete) = load_file_info(id, &db).await?; - let mut path = config.files_dir.clone(); - path.push(&file_id); + let path = config.files_dir.join(&file_id); let mime = Mime::from_str(&content_type).unwrap_or(APPLICATION_OCTET_STREAM); let mut response = match get_view_type(&req, &mime, &path, delete).await { diff --git a/src/upload.rs b/src/upload.rs index 925a67a..490bdc5 100644 --- a/src/upload.rs +++ b/src/upload.rs @@ -103,8 +103,7 @@ async fn create_unique_file( ) -> Result<(String, PathBuf), std::io::Error> { loop { let file_id = gen_file_id(); - let mut file_path = config.files_dir.clone(); - file_path.push(&file_id); + let file_path = config.files_dir.join(&file_id); match OpenOptions::new() .write(true) .create_new(true)