Skip to content

feat(health): persist download_id in file_health table and backfill from history#766

Open
drondeseries wants to merge 4 commits into
javi11:mainfrom
drondeseries:feat/health-persist-download-id
Open

feat(health): persist download_id in file_health table and backfill from history#766
drondeseries wants to merge 4 commits into
javi11:mainfrom
drondeseries:feat/health-persist-download-id

Conversation

@drondeseries

Copy link
Copy Markdown
Contributor

Summary

This PR decouples the library health and automated ARR repair systems from the transient import_history table.

Detailed Changes

  1. Persistent download_id in file_health: Adds a dedicated download_id column to the file_health table to store Sonarr/Radarr tracking IDs. This allows users to prune/delete their import_history (e.g., via HistoryRetentionDays) without breaking automated ARR repairs or Mount-to-Safety-Folder sync checks.
  2. Migrations & Backfill: Includes database migration 034 (SQLite & PostgreSQL) with backfill queries to map existing files in file_health to their original download IDs from the import_history table before it is cleared.
  3. ARR and Importer Hook Integration: Updates API webhook handlers (arrs_handlers.go) and post-import health registration scheduler (health_scheduler.go) to capture and persist the download_id on creation.

@drondeseries drondeseries force-pushed the feat/health-persist-download-id branch from 812ff11 to e4c5b0e Compare July 6, 2026 15:30
drondeseries added a commit to drondeseries/altmount that referenced this pull request Jul 6, 2026
- fix(health): masking must be explicit opt-in (Enabled != nil && Threshold > 0);
  the old nil-or-true condition silently enabled masking by default and a zero
  threshold immediately masked every file, suppressing all repairs
- fix(migration): use exact equality (=) instead of LIKE prefix in migration 034
  backfill; underscore in path names is a LIKE wildcard that could assign the
  wrong download_id from an unrelated release
- fix(quota): guard quota auto-reset on QuotaUsed == 0 to skip idle providers;
  without this every configured-but-unused provider triggered a spurious DB write
  and log line on every tick after its reset time expired
- fix(health): handle sql.ErrNoRows explicitly in IncrementStreamingFailureCount;
  first occurrence (file not yet in file_health) is not a DB error — proceed with
  repair rather than logging a misleading warning
- fix(health): add download_id to GetUnhealthyFiles SELECT and Scan so the health
  worker receives the persisted download_id instead of always falling back to a
  secondary import_history lookup (defeating the purpose of PR javi11#766)
- docs(rar): add clarifying comment to seenNames duplicate detection explaining
  why early break is correct for obfuscated multi-volume archive detection
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