What went wrong?
When a book has multiple formats (e.g. a PDF and an EPUB) and the PDF is the primary file, trying to delete the PDF from the book's "Delete format" dropdown fails with an error toast:
Primary book file cannot be processed as an additional file: 10153
Failed to delete book format: Http failure response for .../api/v1/books/9754/files/10153: 400 OK
The UI explicitly offers the primary file in the delete dropdown (labeled [Primary]) and BookFileService.deleteBookFile even contains cache logic to promote the next format to primary on success — but the backend rejects the request, so deleting a primary format is currently impossible without deleting the whole book.
How can we reproduce it?
- Have a book with two book formats, e.g. PDF (primary) and EPUB.
- Open the book's metadata view → the "..." menu → Delete format.
- Choose the file marked
[Primary] and confirm.
What happened: HTTP 400, "Primary book file cannot be processed as an additional file".
What you expected: the PDF is deleted and the EPUB becomes the primary format.
Root cause (from reading the code)
DELETE /api/v1/books/{bookId}/files/{fileId} routes to AdditionalFileService.deleteAdditionalFile, which calls validateAdditionalFile — a guard added in #463 that throws for the primary file. That guard is correct for the download endpoint (the primary has its own download route), but applying it to delete broke the UI's delete-primary flow.
Notably, the primary file is derived, not stored: BookEntity.getPrimaryBookFile() picks by the library's format priority, falling back to lowest file id. So deleting the primary would automatically promote the next format — no promotion logic is needed. Only deleting the last book format needs to stay blocked (that should be a whole-book delete instead).
What Build of Grimmory are you on?
Stable
Your setup
- Grimmory version: current
develop (0e67549)
- How you're running it: Docker
- Browser: Chrome
- Operating system: Linux
Before submitting
What went wrong?
When a book has multiple formats (e.g. a PDF and an EPUB) and the PDF is the primary file, trying to delete the PDF from the book's "Delete format" dropdown fails with an error toast:
The UI explicitly offers the primary file in the delete dropdown (labeled
[Primary]) andBookFileService.deleteBookFileeven contains cache logic to promote the next format to primary on success — but the backend rejects the request, so deleting a primary format is currently impossible without deleting the whole book.How can we reproduce it?
[Primary]and confirm.What happened: HTTP 400, "Primary book file cannot be processed as an additional file".
What you expected: the PDF is deleted and the EPUB becomes the primary format.
Root cause (from reading the code)
DELETE /api/v1/books/{bookId}/files/{fileId}routes toAdditionalFileService.deleteAdditionalFile, which callsvalidateAdditionalFile— a guard added in #463 that throws for the primary file. That guard is correct for the download endpoint (the primary has its own download route), but applying it to delete broke the UI's delete-primary flow.Notably, the primary file is derived, not stored:
BookEntity.getPrimaryBookFile()picks by the library's format priority, falling back to lowest file id. So deleting the primary would automatically promote the next format — no promotion logic is needed. Only deleting the last book format needs to stay blocked (that should be a whole-book delete instead).What Build of Grimmory are you on?
Stable
Your setup
develop(0e67549)Before submitting