From fbd052bc0474097c43df0554d59148e93b936f13 Mon Sep 17 00:00:00 2001 From: Lionel DARNIS Date: Fri, 7 Aug 2026 19:25:48 +0200 Subject: [PATCH] feat(http-api): cabler la route POST /torrents/delete_all MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le commit precedent ajoutait api_torrents_delete_all et la commande Tauri, mais aucune route HTTP ne l'exposait : la WebUI servie en mode navigateur appelait POST /torrents/delete_all et recevait un 404. Seul le chemin desktop, qui passe par invokeAPI, fonctionnait. Ajoute h_torrents_delete_all, avec remove_files lu en query param et defaut a false, puis enregistre la route dans le bloc !read_only aux cotes de /torrents/{id}/delete. Segment statique, donc prioritaire sur /torrents/{id} — meme schema que /torrents/resolve_magnet. Co-Authored-By: Claude Opus 5 (1M context) --- crates/librqbit/src/http_api/handlers/mod.rs | 3 +++ .../src/http_api/handlers/torrents.rs | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) 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,