fix(api): skip physical books in metadata manager to prevent NPE (#234)

Physical books have no associated file, so calling getPrimaryBookFile()
returns null. The metadata manager was crashing with NullPointerException
when merging/consolidating metadata (authors, genres, etc.) that included
physical books.

This fix skips physical books in writeMetadataToFile() since there is no
file to write metadata to.

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Riccardo Casazza
2026-04-22 17:26:55 -04:00
committed by Zach Yale
co-authored by Claude Opus 4.5
parent 2474cdd4ae
commit ebdcd0bc19
2 changed files with 34 additions and 0 deletions
@@ -59,6 +59,9 @@ public class MetadataManagementService {
for (BookMetadataEntity metadata : metadataList) {
if (metadata.getBook() != null) {
BookEntity book = metadata.getBook();
if (Boolean.TRUE.equals(book.getIsPhysical())) {
continue;
}
boolean bookModified = false;
var primaryFile = book.getPrimaryBookFile();