diff --git a/src/helpers/movies_helper.rs b/src/helpers/movies_helper.rs index 7e79770..80b42b4 100644 --- a/src/helpers/movies_helper.rs +++ b/src/helpers/movies_helper.rs @@ -7,6 +7,7 @@ use crate::data::error::ResultBoxError; use crate::data::movie::Movie; use crate::data::user::UserID; use crate::helpers::{database, posts_helper}; +use crate::utils::user_data_utils::user_data_path; /// Get the list of movies of the current pub fn get_list_user(user_id: &UserID) -> ResultBoxError> { @@ -32,9 +33,14 @@ pub fn does_user_has(user_id: &UserID, movie_id: u64) -> ResultBoxError { pub fn delete(movie: &Movie) -> ResultBoxError { posts_helper::delete_all_with_movie(movie)?; - // TODO : continue implementation + let movie_path = user_data_path(movie.uri.as_ref()); + if movie_path.exists() { + std::fs::remove_file(movie_path)?; + } - Ok(()) + database::DeleteQuery::new(MOVIES_TABLE) + .cond_u64("ID", movie.id) + .exec() } /// Turn a database entry into a movie object