1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-22 21:39:21 +00:00

Finish movie deletion implementation

This commit is contained in:
Pierre HUBERT 2020-07-12 14:26:39 +02:00
parent 2cc8e7da04
commit 3ee2e1843a

View File

@ -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<Vec<Movie>> {
@ -32,9 +33,14 @@ pub fn does_user_has(user_id: &UserID, movie_id: u64) -> ResultBoxError<bool> {
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