Skip to content

Commit 231997b

Browse files
committed
fix: prevent exception that could happen when adding a book
1 parent 9c21f71 commit 231997b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/main/kotlin/io/github/bayang/jelu/service/BookService.kt

+4-2
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,10 @@ class BookService(
152152
// existing book used on UserBook already had an image, backup it
153153
if (!book.image.isNullOrBlank()) {
154154
currentImage = File(properties.files.images, book.image)
155-
backup = File(properties.files.images, "${book.image}.bak")
156-
Files.move(currentImage.toPath(), backup.toPath())
155+
if (currentImage.exists()) {
156+
backup = File(properties.files.images, "${book.image}.bak")
157+
Files.move(currentImage.toPath(), backup.toPath())
158+
}
157159
}
158160
book.image = saveImages(file, book.title, book.id.toString(), userBook.book.image, properties.files.images)
159161
// we had a previous image and we saved a new one : delete the old one

src/main/kotlin/io/github/bayang/jelu/service/metadata/FetchMetadataService.kt

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class FetchMetadataService(
101101
}
102102
if (targetCover.exists() && targetCover.length() > 0) {
103103
parseOpf.image = targetCover.name
104+
logger.trace { "fetch metadata image ${targetCover.name}" }
104105
}
105106
return parseOpf
106107
} else {

0 commit comments

Comments
 (0)