mirror of
https://github.com/tachiyomiorg/tachiyomi-extensions-inspector.git
synced 2025-01-13 17:29:07 +01:00
closes #100
This commit is contained in:
parent
1a99ec76e4
commit
e5e875c54a
@ -42,19 +42,20 @@ object CachedImageResponse {
|
|||||||
val response = fetcher()
|
val response = fetcher()
|
||||||
|
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
val fullPath = "$filePath.tmp"
|
val tmpSavePath = "$filePath.tmp"
|
||||||
val saveFile = File(fullPath)
|
val tmpSaveFile = File(tmpSavePath)
|
||||||
response.body!!.source().saveTo(saveFile)
|
response.body!!.source().saveTo(tmpSaveFile)
|
||||||
|
|
||||||
// find image type
|
// find image type
|
||||||
val imageType = response.headers["content-type"]
|
val imageType = response.headers["content-type"]
|
||||||
?: ImageUtil.findImageType { saveFile.inputStream() }?.mime
|
?: ImageUtil.findImageType { tmpSaveFile.inputStream() }?.mime
|
||||||
?: "image/jpeg"
|
?: "image/jpeg"
|
||||||
.substringAfter("image/")
|
|
||||||
|
|
||||||
saveFile.renameTo(File("$filePath.$imageType"))
|
val actualSavePath = "$filePath.${imageType.substringAfter("/")}"
|
||||||
|
|
||||||
return pathToInputStream(fullPath) to imageType
|
tmpSaveFile.renameTo(File(actualSavePath))
|
||||||
|
|
||||||
|
return pathToInputStream(actualSavePath) to imageType
|
||||||
} else {
|
} else {
|
||||||
response.closeQuietly()
|
response.closeQuietly()
|
||||||
throw Exception("request error! ${response.code}")
|
throw Exception("request error! ${response.code}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user