aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2020-03-01 01:32:10 -0800
committerAllan Wang <me@allanwang.ca>2020-03-01 01:32:10 -0800
commitfd7a35809b360c3ca97e11a794e5f21734868d61 (patch)
tree2c4d73cce9010142280663b669d8def1423be3e2 /app/src
parentc1591dffa764eb16e1f825fceab0c04ac4456af4 (diff)
downloadfrost-fd7a35809b360c3ca97e11a794e5f21734868d61.tar.gz
frost-fd7a35809b360c3ca97e11a794e5f21734868d61.tar.bz2
frost-fd7a35809b360c3ca97e11a794e5f21734868d61.zip
Avoid downloading temp image if it already exists
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt4
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
}