mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-04-19 02:50:54 +00:00
Finish movie deletion implementation
This commit is contained in:
parent
2cc8e7da04
commit
3ee2e1843a
@ -7,6 +7,7 @@ use crate::data::error::ResultBoxError;
|
|||||||
use crate::data::movie::Movie;
|
use crate::data::movie::Movie;
|
||||||
use crate::data::user::UserID;
|
use crate::data::user::UserID;
|
||||||
use crate::helpers::{database, posts_helper};
|
use crate::helpers::{database, posts_helper};
|
||||||
|
use crate::utils::user_data_utils::user_data_path;
|
||||||
|
|
||||||
/// Get the list of movies of the current
|
/// Get the list of movies of the current
|
||||||
pub fn get_list_user(user_id: &UserID) -> ResultBoxError<Vec<Movie>> {
|
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 {
|
pub fn delete(movie: &Movie) -> ResultBoxError {
|
||||||
posts_helper::delete_all_with_movie(movie)?;
|
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
|
/// Turn a database entry into a movie object
|
||||||
|
Loading…
x
Reference in New Issue
Block a user