coil: gracefully handle file handling failures
Wrap the basic fetchArt call in a try statement to prevent exceptions from being unable to open a file from propagating outwards. This allows us to safely degrade when creating mosaics.
This commit is contained in:
@@ -50,10 +50,14 @@ abstract class AuxioFetcher : Fetcher {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return if (settingsManager.useQualityCovers) {
|
return try {
|
||||||
fetchQualityCovers(context, album)
|
if (settingsManager.useQualityCovers) {
|
||||||
} else {
|
fetchQualityCovers(context, album)
|
||||||
fetchMediaStoreCovers(context, album)
|
} else {
|
||||||
|
fetchMediaStoreCovers(context, album)
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,7 +209,7 @@ abstract class AuxioFetcher : Fetcher {
|
|||||||
*/
|
*/
|
||||||
protected fun createMosaic(context: Context, streams: List<InputStream>, size: Size): FetchResult? {
|
protected fun createMosaic(context: Context, streams: List<InputStream>, size: Size): FetchResult? {
|
||||||
if (streams.size < 4) {
|
if (streams.size < 4) {
|
||||||
return streams.getOrNull(0)?.let { stream ->
|
return streams.firstOrNull()?.let { stream ->
|
||||||
return SourceResult(
|
return SourceResult(
|
||||||
source = ImageSource(stream.source().buffer(), context),
|
source = ImageSource(stream.source().buffer(), context),
|
||||||
mimeType = null,
|
mimeType = null,
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import org.oxycblt.auxio.music.Artist
|
|||||||
import org.oxycblt.auxio.music.Genre
|
import org.oxycblt.auxio.music.Genre
|
||||||
import org.oxycblt.auxio.music.Song
|
import org.oxycblt.auxio.music.Song
|
||||||
import org.oxycblt.auxio.ui.Sort
|
import org.oxycblt.auxio.ui.Sort
|
||||||
|
import org.oxycblt.auxio.util.logD
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,9 +82,12 @@ class ArtistImageFetcher private constructor(
|
|||||||
.sortAlbums(artist.albums)
|
.sortAlbums(artist.albums)
|
||||||
|
|
||||||
val results = albums.mapAtMost(4) { album ->
|
val results = albums.mapAtMost(4) { album ->
|
||||||
|
logD("${artist.name} ${album.name}")
|
||||||
fetchArt(context, album)
|
fetchArt(context, album)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logD("OK: ${artist.name}")
|
||||||
|
|
||||||
return createMosaic(context, results, size)
|
return createMosaic(context, results, size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user