Skip to content

Make bulk Scan now obey the scan window and pause in scanner #252

Done

Description

@nazmolla

Summary

A bulk "Scan now" (library, show, several titles) force-scans every title, and forced scans ignore both the scan window and a manual pause, so a big batch runs straight through the end of the window and nothing stops it short of restarting the app.

Evidence

  • cleanplex/web/routes/scanner_routes.py:302 — library Scan now calls force_scan_job for every chosen title
  • cleanplex/web/routes/scanner_routes.py:151 — _queue_rescan(now=True) (titles, show) does the same
  • cleanplex/scanner.py:1101 — a running forced scan ignores _paused; :1109 it also ignores the window end
  • cleanplex/scanner.py:1210 — outside the window, workers still claim force jobs; :1230 claiming any job calls resume_scanner(), so POST /api/scan/pause is undone by the next claim
  • Prod 2026-12-04: 234 titles force-queued at 17:54 kept scanning after the window closed at 18:00 (force_scan=True, in_window=False)

Impact

Scanning (CPU-heavy) runs for hours outside the hours the user set, and there is no way to stop it for a while.

Proposed Work

  • Split the force flag: 2 = single-title Scan now (may run outside the window, as Stop idle worker pausing abort another worker's forced scan #201 decided), 1 = bulk Scan now (jumps the queue, obeys the window)
  • A persisted pause with an optional end time (scan_paused_until setting): POST /api/scan/pause {"until": "01:00"}; while it holds no job is claimed and running scans, forced ones included, are re-queued
  • Status endpoints report paused_until

Acceptance Criteria

  • A bulk Scan now outside the window queues titles first in line but none starts until the window opens; a running one stops at the window end
  • A single-title Scan now still starts outside the window
  • While a manual pause holds, no scan (forced or not) is claimed and a running forced scan is re-queued
  • The pause survives a restart and lifts itself at its end time

Activity

  1. added
    bug
    backend
    high-priority
    reliability
    on Dec 4, 2026
  2. added a commit that references this issue on Dec 5, 2026
    dda4e9f
  3. nazmolla commented on Dec 5, 2026

    @nazmolla
    OwnerAuthor

    Resolution

    Status: Fixed

    What was done

    • Two force levels: FORCE_NOW (one title, may run outside the window) and FORCE_QUEUED (bulk, waits for the window) — cleanplex/database.py, claim_next_scan_job(force_only=True) claims only FORCE_NOW
    • Bulk Scan now (titles, show, library) uses FORCE_QUEUED — cleanplex/web/routes/scanner_routes.py _now_level
    • Persisted manual pause (scan_paused_until) that stops every scan, forced ones included, and lifts itself — cleanplex/scanner.py set_hold / load_hold / hold_active; POST /api/scan/pause {"until": "HH:MM"}
    • A forced job re-queued by the window end or the pause keeps its place at the front

    How to verify

    • pytest tests/unit/test_scanner_generators.py tests/integration/test_routes_scanner.py tests/unit/test_database.py (bulk forced scan waits outside the window and stops at its end; pause stops a single-title forced scan; force_only skips bulk jobs; pause persists and expires)
    • Prod 0.2.7: paused until 01:00 with manual_pause: true, no scans running at 19:xx

    Related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendbughigh-priorityreliability

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions