refactor: construct filepaths more idiomatically
This commit is contained in:
parent
e538d93d80
commit
900d9ac449
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue