Pacote de endurecimento focado em rodar 24/7 no NAS sem surpresas.
DB / persistence
- Register a datetime adapter so Python 3.12+ stops warning about the
deprecated default; emits "YYYY-MM-DD HH:MM:SS[.ffffff]" to preserve
existing string-based comparisons in get_enhanced_stats.
- PRAGMA journal_mode=WAL on init (concurrency + crash safety on the
NAS) and synchronous=NORMAL per connection (cheap, WAL-safe).
- Two composite indexes: (author, subreddit) and (media_type,
downloaded_at) — speed up the gallery and cleanup queries.
API surface
- New /health router with no auth dep, returns booleans for db /
ffmpeg / downloads_writable / scheduler plus the package version and
whether Basic Auth is configured. Reachable even when
RMC_AUTH_USER/PASS are set, so it can be wired into Container
Manager / external monitors.
- Refactor: move require_auth() from app-level dependency to per-router
include_router(..., dependencies=[require_auth()]); /health is the
only route that opts out.
- Rate limit (60/min per IP+path) on every POST/PUT/DELETE in config:
subreddits, users, blacklist.*, settings.* — protects config.yaml
from runaway loops or spam.
Observability
- Replace silent `except Exception` in main and scheduler with
exc_info=True logging and a new collector_status["last_error"] field
surfaced via /api/collector/status, so a failed 3am scheduled run
isn't invisible.
- RotatingFileHandler (10 MB × 5 backups) caps collector.log around
60 MB on the NAS volume.
Quality
- tests/test_router_scheduler.py covers status / config (interval +
cron) / history / run-now / collector run / individual collect
validation. scheduler.py coverage 25% → 55%, total 55% → 58%
(135 → 151 tests).
- Type extractors.gfycat (cast yt-dlp Any to str), removed from the
mypy ignore list. First module destravado — pattern for the rest.
Verified locally: ruff + mypy + 151 pytest green; docker container
boots healthy in 6s; PRAGMA journal_mode reports `wal`; 70 POSTs to
/api/subreddits returned 60 OK + 10 HTTP 429.