refactor: construct filepaths more idiomatically

This commit is contained in:
neri 2023-01-23 11:23:48 +01:00
parent e538d93d80
commit 900d9ac449
2 changed files with 2 additions and 4 deletions

View File

@ -37,8 +37,7 @@ pub async fn download(
) -> Result<HttpResponse, Error> {
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 {

View File

@ -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)