From 49b92e9ac9b88db014cc6d228b4a27315ef52c4c Mon Sep 17 00:00:00 2001 From: Colin White Date: Thu, 14 Nov 2024 12:17:04 -0800 Subject: [PATCH] Add missing flush calls to DiskLruCache. (#2684) * Add missing flush calls to DiskLruCache. * Clean up. --- coil-core/src/commonMain/kotlin/coil3/disk/DiskLruCache.kt | 6 +++++- 1 file changed, 5 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 ae5d5fdb3e..664b34fd44 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()) { @@ -519,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 } @@ -553,6 +556,7 @@ internal class DiskLruCache( writeByte(' '.code) writeUtf8(entry.key) writeByte('\n'.code) + flush() } lruEntries.remove(entry.key)