From c141a1b9d4561b74a675fe6215fe20c47f019c45 Mon Sep 17 00:00:00 2001 From: Colin White Date: Wed, 13 Nov 2024 21:28:04 -0800 Subject: [PATCH 1/2] Add missing flush calls to DiskLruCache. --- coil-core/src/commonMain/kotlin/coil3/disk/DiskLruCache.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/coil-core/src/commonMain/kotlin/coil3/disk/DiskLruCache.kt b/coil-core/src/commonMain/kotlin/coil3/disk/DiskLruCache.kt index ae5d5fdb3e..ee3fa932d9 100644 --- a/coil-core/src/commonMain/kotlin/coil3/disk/DiskLruCache.kt +++ b/coil-core/src/commonMain/kotlin/coil3/disk/DiskLruCache.kt @@ -370,6 +370,7 @@ internal class DiskLruCache( writeByte(' '.code) writeUtf8(key) writeByte('\n'.code) + flush() } if (journalRewriteRequired()) { @@ -553,6 +554,7 @@ internal class DiskLruCache( writeByte(' '.code) writeUtf8(entry.key) writeByte('\n'.code) + flush() } lruEntries.remove(entry.key) From 2db319dde40f4b5389c7686ed08f5cde866a40f9 Mon Sep 17 00:00:00 2001 From: Colin White Date: Wed, 13 Nov 2024 21:35:12 -0800 Subject: [PATCH 2/2] Clean up. --- coil-core/src/commonMain/kotlin/coil3/disk/DiskLruCache.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/coil-core/src/commonMain/kotlin/coil3/disk/DiskLruCache.kt b/coil-core/src/commonMain/kotlin/coil3/disk/DiskLruCache.kt index ee3fa932d9..664b34fd44 100644 --- a/coil-core/src/commonMain/kotlin/coil3/disk/DiskLruCache.kt +++ b/coil-core/src/commonMain/kotlin/coil3/disk/DiskLruCache.kt @@ -520,7 +520,9 @@ internal class DiskLruCache( val entry = lruEntries[key] ?: return false val removed = removeEntry(entry) - if (removed && size <= maxSize) mostRecentTrimFailed = false + if (removed && size <= maxSize) { + mostRecentTrimFailed = false + } return removed }