From d7ad64ab7b779886af75d2500365372921c9181e Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Tue, 13 Sep 2022 16:01:16 +0200 Subject: Fix: url for delete_upload Url passed at `delete_upload` could be different into the filesystem, so replace the first part of the url with the environment var --- src/files.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/files.rs b/src/files.rs index 7addda2..f72070b 100644 --- a/src/files.rs +++ b/src/files.rs @@ -57,7 +57,14 @@ pub async fn upload( /// Delete a file from the filesystem pub fn delete_upload(filename: &String) -> Result<(), AppError> { - fs::remove_file(filename)?; + let last_slash_index = filename.rfind('/').unwrap(); + let path = format!( + "{}/{}", + CONFIG.save_file_base_path, + &filename[last_slash_index + 1..] + ); + + fs::remove_file(path)?; Ok(()) } -- cgit v1.2.3-71-g8e6c