From f1330ad4a484ad1715751e4addb8f53edc122113 Mon Sep 17 00:00:00 2001 From: Zynh0722 Date: Sat, 8 Apr 2023 08:16:56 -0700 Subject: [PATCH] cleanup temp files --- src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index b829ab0..dc4e9f3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,9 +77,8 @@ async fn upload(mut body: Multipart) -> Result { continue; }; - if !path_is_valid(&file_name) { - return Err((StatusCode::BAD_REQUEST, "Invalid Filename >:(".to_owned())) + return Err((StatusCode::BAD_REQUEST, "Invalid Filename >:(".to_owned())); } let path = cache_folder.join(file_name); @@ -88,7 +87,9 @@ async fn upload(mut body: Multipart) -> Result { stream_to_file(&path, field).await? } - tracing::debug!("{cache_folder:?}"); + remove_dir(cache_folder) + .await + .map_err(|err| (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()))?; Ok(Redirect::to("/")) } @@ -131,7 +132,6 @@ fn path_is_valid(path: &str) -> bool { let mut components = Path::new(path).components().peekable(); if let Some(first) = components.peek() { - tracing::debug!("{:?}", &first); if !matches!(first, std::path::Component::Normal(_)) { return false; }