From 17256daf1ed763b0f7a0fc2d57c5c15bf64b0952 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 1 Sep 2020 08:45:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9B=BE=E7=89=87=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/help/BookHelp.kt | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/BookHelp.kt b/app/src/main/java/io/legado/app/help/BookHelp.kt index 94707b985..89a2bf41b 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.kt @@ -96,16 +96,21 @@ object BookHelp { } downloadImages.add(src) val analyzeUrl = AnalyzeUrl(src) - analyzeUrl.getImageBytes(book.origin)?.let { - FileUtils.createFileIfNotExist( - downloadDir, - cacheFolderName, - book.getFolderName(), - cacheImageFolderName, - "${MD5Utils.md5Encode16(src)}${getImageSuffix(src)}" - ).writeBytes(it) + try { + analyzeUrl.getImageBytes(book.origin)?.let { + FileUtils.createFileIfNotExist( + downloadDir, + cacheFolderName, + book.getFolderName(), + cacheImageFolderName, + "${MD5Utils.md5Encode16(src)}${getImageSuffix(src)}" + ).writeBytes(it) + } + } catch (e: Exception) { + e.printStackTrace() + } finally { + downloadImages.remove(src) } - downloadImages.remove(src) } fun getImage(book: Book, src: String): File {