Removes logs from blossom fetcher
This commit is contained in:
@@ -33,6 +33,7 @@ import coil3.network.NetworkFetcher
|
|||||||
import coil3.network.okhttp.asNetworkClient
|
import coil3.network.okhttp.asNetworkClient
|
||||||
import coil3.request.Options
|
import coil3.request.Options
|
||||||
import com.vitorpamplona.amethyst.service.uploads.blossom.bud10.BlossomServerResolver
|
import com.vitorpamplona.amethyst.service.uploads.blossom.bud10.BlossomServerResolver
|
||||||
|
import com.vitorpamplona.quartz.utils.startsWithIgnoreCase
|
||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import kotlin.coroutines.cancellation.CancellationException
|
import kotlin.coroutines.cancellation.CancellationException
|
||||||
|
|
||||||
@@ -43,18 +44,14 @@ class BlossomFetcher(
|
|||||||
private val blossomServerResolver: BlossomServerResolver,
|
private val blossomServerResolver: BlossomServerResolver,
|
||||||
private val networkFetcher: (url: String) -> Fetcher,
|
private val networkFetcher: (url: String) -> Fetcher,
|
||||||
) : Fetcher {
|
) : Fetcher {
|
||||||
override suspend fun fetch(): FetchResult? {
|
override suspend fun fetch(): FetchResult? =
|
||||||
println("BlossomFetcher: starting $data")
|
try {
|
||||||
return try {
|
|
||||||
val urlResult = blossomServerResolver.findServers(data.toString())
|
val urlResult = blossomServerResolver.findServers(data.toString())
|
||||||
println("BlossomFetcher: finished $data to ${urlResult?.serverUrl}")
|
|
||||||
networkFetcher(urlResult?.serverUrl ?: data.toString()).fetch()
|
networkFetcher(urlResult?.serverUrl ?: data.toString()).fetch()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
if (e is CancellationException) throw e
|
if (e is CancellationException) throw e
|
||||||
println("BlossomFetcher: cancelled or error: $e $data")
|
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@OptIn(ExperimentalCoilApi::class)
|
@OptIn(ExperimentalCoilApi::class)
|
||||||
class Factory(
|
class Factory(
|
||||||
@@ -68,11 +65,7 @@ class BlossomFetcher(
|
|||||||
options: Options,
|
options: Options,
|
||||||
imageLoader: ImageLoader,
|
imageLoader: ImageLoader,
|
||||||
): Fetcher? {
|
): Fetcher? {
|
||||||
println("BlossomFetcher: PreFactory $data")
|
|
||||||
if (!isApplicable(data)) return null
|
if (!isApplicable(data)) return null
|
||||||
|
|
||||||
println("BlossomFetcher: Factory $data")
|
|
||||||
|
|
||||||
return BlossomFetcher(options, data, blossomServerResolver) { url ->
|
return BlossomFetcher(options, data, blossomServerResolver) { url ->
|
||||||
NetworkFetcher(
|
NetworkFetcher(
|
||||||
url = url,
|
url = url,
|
||||||
@@ -86,6 +79,6 @@ class BlossomFetcher(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isApplicable(data: Uri): Boolean = data.scheme?.lowercase() == "blossom"
|
private fun isApplicable(data: Uri): Boolean = data.scheme?.startsWithIgnoreCase("blossom", "BLOSSOM") == true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user