feat(downloads): ordered preferred_methods list honored for web tasks

The agent ignored its config.toml method preference for web-driven downloads
(only the local `unarr download` command read it), and resolveMethod tried
torrent first in auto mode — so a 'debrid only' user still got torrent tasks.

- config: preferred_methods (ordered list, e.g. ["debrid","usenet"]) with
  MethodOrder() resolution; back-compat with the singular preferred_method.
  Methods absent from the list are disabled (debrid-only never torrents).
- resolveMethod/tryFallback honor the config order (gating, no fallback to a
  method outside the list) over the per-task preference.
- report preferred_methods on register so the web honors it (resolves debrid,
  gates the P2P stream fallback).
- enable the usenet downloader when usenet is listed (it was never enabled).
- config_menu: ordered presets (debrid-only, debrid→torrent, debrid→usenet…).

Tests: resolveMethod gating + fallback within/outside the list.
This commit is contained in:
Deivid Soto 2026-06-14 12:51:32 +02:00
parent 523ecc724a
commit c7ee0c0a28
8 changed files with 256 additions and 45 deletions

View file

@ -41,6 +41,9 @@ type DaemonConfig struct {
HWDevices []string // device files + driver bins detected at probe time
AutoUpgrade bool // honor server-flagged upgrades by downloading + restarting (default: true)
Downlink string // realtime downlink transport: "auto" (SSE+long-poll fallback) | "sse" | "poll"
// PreferredMethods is the ordered download-method preference from config.toml
// (e.g. ["debrid","usenet"]). Reported to the web so it honours the gating.
PreferredMethods []string
}
// Daemon manages agent registration and the sync loop.
@ -165,6 +168,7 @@ func (d *Daemon) Register(ctx context.Context) error {
VPNServer: d.vpnServer,
FunnelURL: d.funnelURL,
IsDocker: RunningInDocker(),
PreferredMethods: d.cfg.PreferredMethods,
}
if free, total, err := DiskInfo(d.cfg.DownloadDir); err == nil {
req.DiskFreeBytes = free