fix: delete a library's ebooks when the library is deleted #57
No reviewers
Labels
No labels
bug
critical
ebook-branch
high
low
main
medium
release-blocker
security
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
jfro/fuzzy_catalog!57
Loading…
Reference in a new issue
No description provided.
Delete branch "jtk/library-delete-ebooks"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Deleting a library nilified
ebooks.library_id(the FK ison_delete: :nilify_all). That left ebook records with no library, which no scan would ever clean up and which kept showing as downloads on their books.Change (
Libraries.delete_library/1)Repo.transact. I left the FK alone, so no migration is needed. The old nilify behavior can't bite here because the ebooks are already gone by the time the library row is deleted.books.cover_image_key(the ProcessWorker gives new books the ebook's cover, so this is common) or by another ebook. Covers are deleted after the commit, so a rollback can't leave broken images.Left as is, open to change
ebookcollection item, even when the deleted library had their only ebook. Removing it could undo something the user added by hand. I can drop it when no ebook is left, if you'd like.Repo.get!and get discarded.JobFailureHandlerskips them because the ebook is gone. The admin UI also blocks deleting a library while it's scanning.Tests
cover_image_keyis intact; summary logs checked.mix precommitpasses.Fixes #24
Review from Nye (approved)
Checked: no other table references ebooks; delete_all with select returns {count, keys} on Postgres; covers deleted after commit and only when no book/other ebook uses the key; Storage delete returns :ok | {:error, _}; logs have library id/path/counts and per-key warnings.
Nits (non-blocking):