This repository has been archived by the owner on Nov 12, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 886
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Caused by us using the same disk cache location on Android as the previous Coil implementation. This results in any existing Coil-originated disk cache being incompatible with Compose Image Loader. Fixed by using a different cache folder, and deleting the remaining Coil cache folder (if exists).
- Loading branch information
1 parent
a8c2a19
commit 8a257ab
Showing
3 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...mageloading/src/androidMain/kotlin/app/tivi/common/imageloading/CoilCleanupInitializer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2023, Christopher Banes and the Tivi project contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package app.tivi.common.imageloading | ||
|
||
import android.app.Application | ||
import app.tivi.appinitializers.AppInitializer | ||
import app.tivi.util.AppCoroutineDispatchers | ||
import kotlinx.coroutines.DelicateCoroutinesApi | ||
import kotlinx.coroutines.GlobalScope | ||
import kotlinx.coroutines.launch | ||
import kotlinx.coroutines.withContext | ||
import me.tatarka.inject.annotations.Inject | ||
|
||
@Inject | ||
class CoilCleanupInitializer( | ||
private val application: Application, | ||
private val dispatchers: AppCoroutineDispatchers, | ||
) : AppInitializer { | ||
@OptIn(DelicateCoroutinesApi::class) | ||
override fun initialize() { | ||
GlobalScope.launch { | ||
withContext(dispatchers.io) { | ||
// We delete Coil's image_cache folder to claim back space for the user | ||
val coilCache = application.cacheDir.resolve("image_cache") | ||
if (coilCache.exists()) { | ||
coilCache.deleteRecursively() | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters