Skip to main content

rekey_book

Function rekey_book 

Source
async fn rekey_book(
    pool: &SqlitePool,
    old_fp: &str,
    new_fp: &str,
) -> Result<(), Error>
Expand description

Re-keys a single book row from old_fp to new_fp, preserving all associated data (reading state, thumbnails, TOC, authors, categories).

All child tables use ON DELETE CASCADE, so deleting the old books row at the end cascades cleanly. We update each child table explicitly first to transfer data to the new fingerprint before the cascade fires.

The library_books UPDATE is intentionally global (not scoped to a single library) because the subsequent DELETE cascades globally — scoping the UPDATE would silently drop other libraries’ associations.