feat: remove files for one season or episode

DELETE /api/series/{id}/seasons/{n}/files and
DELETE /api/episodes/{id}/files unlink what the scope covers, drop the
matching media_files rows and clear wanted, in one action. 204 on
success, 404 for an unknown season or episode, and a scope with nothing
on disk still clears intent.

Season and episode rows stay: TMDB owns that metadata and the next
refresh would recreate them.

The three scopes share one unlink path. A whole series still resolves to
its title folder (§7.4, atomic); a season or episode resolves to the
recorded file and nothing else, so a narrow call cannot reach a sibling.
The intent clear goes through arr_core::tracking::apply_tracked(false),
the same §4.1 rule #171 landed.

An episode whose file just went is set back to 'missing' when it was
'available', matching what a failed import already does. Closes #174.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Miguel Palhas
2026-08-24 16:43:53 +01:00
parent 4a611a6794
commit 64e28e5930
16 changed files with 1096 additions and 71 deletions
+7
View File
@@ -90,7 +90,9 @@ fn api_router() -> OpenApiRouter<AppState> {
.routes(routes!(series::get, series::update, series::delete))
.routes(routes!(series::seasons, series::create_season))
.routes(routes!(series::update_season))
.routes(routes!(series::delete_season_files))
.routes(routes!(series::get_episode, series::update_episode))
.routes(routes!(series::delete_episode_files))
.routes(routes!(series::search_episode))
.routes(routes!(series::episode_releases))
.routes(routes!(series::grab_episode))
@@ -334,6 +336,11 @@ mod tests {
"/api/series/{series_id}/seasons/{season_number}/releases/{release_id}/grab",
"post",
),
(
"/api/series/{series_id}/seasons/{season_number}/files",
"delete",
),
("/api/episodes/{episode_id}/files", "delete"),
("/api/queues/attention", "get"),
("/api/trailer", "get"),
("/api/series", "get"),