diff options
author | Allan Wang <me@allanwang.ca> | 2020-03-01 01:32:10 -0800 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2020-03-01 01:32:10 -0800 |
commit | fd7a35809b360c3ca97e11a794e5f21734868d61 (patch) | |
tree | 2c4d73cce9010142280663b669d8def1423be3e2 /app | |
parent | c1591dffa764eb16e1f825fceab0c04ac4456af4 (diff) | |
download | frost-fd7a35809b360c3ca97e11a794e5f21734868d61.tar.gz frost-fd7a35809b360c3ca97e11a794e5f21734868d61.tar.bz2 frost-fd7a35809b360c3ca97e11a794e5f21734868d61.zip |
Avoid downloading temp image if it already exists
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt index 4abdd15f..f12ca7aa 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt @@ -322,7 +322,9 @@ class ImageActivity : KauBaseActivity() { val body = response.body ?: throw IOException("Failed to retrieve image body") val tempFile = File(cacheDir(this@ImageActivity), "$imageHash.$imgExtension") - tempFile.copyFromInputStream(body.byteStream()) + if (!tempFile.exists() || tempFile.length() == 0L) { + tempFile.copyFromInputStream(body.byteStream()) + } tempFile } |