async fn import_orphan_reading_states(
tx: &mut Transaction<'_, Sqlite>,
library_id: i64,
reading_states_dir: &Path,
already_imported: &HashSet<Fp>,
) -> usizeExpand description
Imports reading states from .reading-states/ that are not in already_imported.
The already_imported set contains fingerprints whose reading state was
already written from .metadata.json. Skipping those keeps the migration
idempotent and ensures the metadata file’s version takes precedence.
For each fingerprint not yet imported, a stub books row is inserted first
to satisfy the foreign key constraint. A follow-up migration is responsible
for cleaning up any stub rows whose files are no longer on disk.
Returns the number of reading states imported.