"""Library scanning and the stable per-book id shared across progress.py, blocks.py, and remote.py.""" from __future__ import annotations import hashlib from pathlib import Path def _book_id(path: Path) -> str: # Identifies a book by its resolved path for now. Once the sync API exists, # this should switch to whatever stable id diora assigns server-side. return hashlib.sha256(str(path.resolve()).encode()).hexdigest()[:16] def scan_library(library_dir: Path) -> list[Path]: if not library_dir.exists(): return [] return sorted(library_dir.rglob("*.epub"))