File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
booklore-api/src/main/java/com/adityachandel/booklore/service/opds Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -604,6 +604,13 @@ private String now() {
604604 return DateTimeFormatter .ISO_INSTANT .format (java .time .Instant .now ());
605605 }
606606
607+ private boolean hasValidFilePath (Book book ) {
608+ return book .getFileName () != null
609+ && book .getLibraryPath () != null
610+ && book .getLibraryPath ().getPath () != null
611+ && book .getFileSubPath () != null ;
612+ }
613+
607614 private String fileMimeType (Book book ) {
608615 if (book == null || book .getBookType () == null ) {
609616 return "application/octet-stream" ;
@@ -612,7 +619,7 @@ private String fileMimeType(Book book) {
612619 case PDF -> "application/pdf" ;
613620 case EPUB -> "application/epub+zip" ;
614621 case FB2 -> {
615- if (book . getFileName () != null ) {
622+ if (hasValidFilePath ( book ) ) {
616623 ArchiveUtils .ArchiveType type = ArchiveUtils .detectArchiveType (new File (FileUtils .getBookFullPath (book )));
617624 if (type == ArchiveUtils .ArchiveType .ZIP ) {
618625 yield "application/zip" ;
@@ -632,7 +639,7 @@ yield switch (book.getArchiveType()) {
632639 };
633640 }
634641
635- if (book . getFileName () != null ) {
642+ if (hasValidFilePath ( book ) ) {
636643 ArchiveUtils .ArchiveType type = ArchiveUtils .detectArchiveType (new File (FileUtils .getBookFullPath (book )));
637644 yield switch (type ) {
638645 case RAR -> "application/vnd.comicbook-rar" ;
You can’t perform that action at this time.
0 commit comments