Skip to content

Upgraded/replaced media files linger as dead playable versions until the next full scan #311

Closed

Description

@Quick104

Bug

When a file is upgraded or replaced (delete + import, e.g. Radarr-style via an autoscan source), the deleted file's media_files row is not marked missing until the next full library scan (daily on dev). Until then the stale row is still offered as a playable version and playback fails with "Source media file is missing" (observed on dev item movie-tmdb-1339713, which had two dead versions).

Root causes

  1. Autoscan drops delete events. File-scope changes whose path no longer exists fail scantrigger resolution (ClassifyPath stats the path → RequestError) and are silently skipped in resolveAndClaim/resolveChange. Only the import half of an upgrade triggers a scoped scan, and ScanFile reconciles nothing.
  2. scanner.file_removal_grace is dead config. FileRepository.DeleteMissing(grace) has no callers, and empty_trash_after_scan purges missing-marked rows folder-wide immediately on every scan — so the advertised removal delay does not exist.

Fix direction

  • Resolve vanished paths to a reconciling subtree scan (video file → parent dir; removed dir → itself; entry directly under a root → guarded library scan), with guards so an unmounted share never triggers reconciliation. Missing-marked files are already hidden from all client surfaces instantly, so prompt marking closes the dead-version window from ~24h to about a minute.
  • Make trash-emptying honor file_removal_grace so rows survive (hidden) for the grace window and a file that reappears restores without re-probing/re-matching.

AI-use disclosure: investigated and drafted with Claude Code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions