diff --git a/crates/librqbit/src/http_api/handlers/mod.rs b/crates/librqbit/src/http_api/handlers/mod.rs index ff3b43d..a87d725 100644 --- a/crates/librqbit/src/http_api/handlers/mod.rs +++ b/crates/librqbit/src/http_api/handlers/mod.rs @@ -112,6 +112,9 @@ pub fn make_api_router(state: ApiState) -> Router { "/torrents/{id}/delete", post(torrents::h_torrent_action_delete), ) + // Segment statique, donc prioritaire sur /torrents/{id} — meme + // schema que /torrents/resolve_magnet juste au-dessus. + .route("/torrents/delete_all", post(torrents::h_torrents_delete_all)) .route( "/torrents/{id}/update_only_files", post(torrents::h_torrent_action_update_only_files), diff --git a/crates/librqbit/src/http_api/handlers/torrents.rs b/crates/librqbit/src/http_api/handlers/torrents.rs index 75ffb09..6e3c2f5 100644 --- a/crates/librqbit/src/http_api/handlers/torrents.rs +++ b/crates/librqbit/src/http_api/handlers/torrents.rs @@ -146,6 +146,25 @@ pub async fn h_torrent_action_delete( .map(axum::Json) } +#[derive(Deserialize, Default)] +pub struct DeleteAllQueryParams { + /// Supprime aussi les donnees telechargees. Absent = false, on ne garde + /// que la suppression des torrents. + #[serde(default)] + pub remove_files: bool, +} + +pub async fn h_torrents_delete_all( + State(state): State, + Query(params): Query, +) -> Result { + state + .api + .api_torrents_delete_all(params.remove_files) + .await + .map(axum::Json) +} + #[derive(Deserialize)] pub struct UpdateOnlyFilesRequest { only_files: Vec,