Remove covers on error. #334

This commit is contained in:
len 2016-06-06 20:45:22 +02:00
parent 93fc5944f3
commit 59b90a94d0

View file

@ -29,10 +29,15 @@ class MangaDataFetcher(private val networkFetcher: DataFetcher<InputStream>,
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
}
}
}