From 546d1e9e736d0e20c09dd014e4edaea52122e773 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Tue, 3 Mar 2026 19:30:39 -0500 Subject: [PATCH] Protects against invalid URLs --- .../amethyst/ui/actions/MediaSaverToDisk.kt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/MediaSaverToDisk.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/MediaSaverToDisk.kt index 0e419e04c..0430a5029 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/MediaSaverToDisk.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/MediaSaverToDisk.kt @@ -97,15 +97,16 @@ object MediaSaverToDisk { onSuccess: () -> Any?, onError: (Throwable) -> Any?, ) { - val client = okHttpClient(url) - val request = - Request - .Builder() - .get() - .url(url) - .build() - try { + val client = okHttpClient(url) + + val request = + Request + .Builder() + .get() + .url(url) + .build() + client.newCall(request).executeAsync().use { response -> withContext(Dispatchers.IO) { check(response.isSuccessful)