From 59b90a94d05c7b271c92b6ceba12da5cc6827323 Mon Sep 17 00:00:00 2001 From: len Date: Mon, 6 Jun 2016 20:45:22 +0200 Subject: [PATCH] Remove covers on error. #334 --- .../kanade/tachiyomi/data/glide/MangaDataFetcher.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/glide/MangaDataFetcher.kt b/app/src/main/java/eu/kanade/tachiyomi/data/glide/MangaDataFetcher.kt index 8e1b0ee56..8d3453fc4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/glide/MangaDataFetcher.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/glide/MangaDataFetcher.kt @@ -29,10 +29,15 @@ class MangaDataFetcher(private val networkFetcher: DataFetcher, if (!file.exists()) { file.parentFile.mkdirs() networkFetcher.loadData(priority)?.let { - it.use { input -> - file.outputStream().use { output -> - input.copyTo(output) + try { + it.use { input -> + file.outputStream().use { output -> + input.copyTo(output) + } } + } catch (e: Exception) { + file.delete() + throw e } } }