forked from neri/datatrash
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> {
|
) -> Result<HttpResponse, Error> {
|
||||||
let id = req.match_info().query("id");
|
let id = req.match_info().query("id");
|
||||||
let (file_id, file_name, valid_till, content_type, delete) = load_file_info(id, &db).await?;
|
let (file_id, file_name, valid_till, content_type, delete) = load_file_info(id, &db).await?;
|
||||||
let mut path = config.files_dir.clone();
|
let path = config.files_dir.join(&file_id);
|
||||||
path.push(&file_id);
|
|
||||||
|
|
||||||
let mime = Mime::from_str(&content_type).unwrap_or(APPLICATION_OCTET_STREAM);
|
let mime = Mime::from_str(&content_type).unwrap_or(APPLICATION_OCTET_STREAM);
|
||||||
let mut response = match get_view_type(&req, &mime, &path, delete).await {
|
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> {
|
) -> Result<(String, PathBuf), std::io::Error> {
|
||||||
loop {
|
loop {
|
||||||
let file_id = gen_file_id();
|
let file_id = gen_file_id();
|
||||||
let mut file_path = config.files_dir.clone();
|
let file_path = config.files_dir.join(&file_id);
|
||||||
file_path.push(&file_id);
|
|
||||||
match OpenOptions::new()
|
match OpenOptions::new()
|
||||||
.write(true)
|
.write(true)
|
||||||
.create_new(true)
|
.create_new(true)
|
||||||
|
|
Loading…
Reference in New Issue