Skip to content

fix(queue): respect torrent preservation when removing downloads - #171

Open
EasyAsABC123 wants to merge 1 commit into
Chaptarr:developfrom
EasyAsABC123:fix/queue-preservation-policy
Open

EasyAsABC123 wants to merge 1 commit into
Chaptarr:developfrom
EasyAsABC123:fix/queue-preservation-policy

Conversation

@EasyAsABC123

Copy link
Copy Markdown

Description

Queue removal currently deletes a torrent and its files directly, bypassing the existing download preservation policy. A completed download that fails import matching can therefore be deleted when removed and blocklisted through the queue, even when its indexer has Keep seeding permanently (NeverMoveOnImport) enabled. Automatic cleanup already checks this policy; the queue endpoints do not.

Use IDownloadImportModeResolver to enforce the same policy for individual and bulk queue removal. A protected deletion returns HTTP 400 with instructions to choose Ignore Download or use removeFromClient=false. Bulk requests check every tracked download before changing any pending releases or client items, preventing partial deletion when a protected item appears later in the selection.

Ignoring, blocklisting, and changing category without client deletion remain available. Unprotected downloads retain their existing behavior. The guard also honors the resolver's existing protection for unmanaged torrents on clients configured with CopyUnmanagedDownloads.

Intentional behavior change: explicit queue deletion no longer overrides these opt-in preservation settings. Users who intend to delete a protected torrent and its files can still do so directly in their download client. This does not change client-side ratio/time limits or enable preservation settings by default.

Related: #129 clarifies preservation setting labels/help text; this PR adds enforcement to queue removal and does not depend on that wording change.

Database Migration

NO.

How was this tested?

Native Linux, .NET 10, based directly on current upstream develop (7a06004).

dotnet test src/Chaptarr.Core.Test/Chaptarr.Core.Test.csproj -c Release -p:WarningsNotAsErrors=NU1902

Full suite: 3,027 passed, 0 failed; the production-reader fixture is skipped by the test runner. NU1902 is demoted for the existing Microsoft.Build.Tasks.Git 8.0.0 advisory; no dependencies are changed.

Seven new regression cases exercise:

  • Protected single-item deletion with and without blocklisting.
  • Bulk preflight before pending-release or unprotected-client mutations.
  • Ignoring, blocklisting, and changing category while preserving the client item.
  • Unprotected client deletion retaining its existing behavior.

Reproduction:

  1. Enable Keep seeding permanently for a torrent indexer and grab a torrent through it.
  2. From the queue, choose Remove from Download Client, optionally with blocklisting.
  3. Before: the torrent and files are deleted. After: the request is rejected before mutation, with instructions for retaining the torrent.
  4. Choose Ignore Download instead; Chaptarr can stop tracking it without deleting the client item.

The same guard was also deployed and checked in a live Chaptarr instance: the queue/system APIs remained healthy, preservation settings persisted across restart, and the health endpoint reported no issues. No homelab configuration or deployment artifacts are included here.

@EasyAsABC123
EasyAsABC123 marked this pull request as ready for review September 22, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant