Skip to content

Commit 1a5ac61

Browse files
fixup! TW-2881 Implement main MXC cache manager with tests
fixup! TW-2881 Implement main MXC cache manager with tests
1 parent 624dbd1 commit 1a5ac61

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/data/cache/mxc_cache_manager.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// lib/data/cache/mxc_cache_manager.dart
2+
import 'dart:async';
23
import 'dart:typed_data';
34
import 'package:matrix/matrix.dart';
45
import 'database/cache_database_interface.dart';
@@ -195,7 +196,9 @@ class MxcCacheManager {
195196
memorySizeBytes: memoryStats.sizeBytes,
196197
memoryUtilization: memoryStats.utilizationPercent,
197198
diskSizeBytes: diskSize,
198-
diskUtilization: (diskSize / _config.diskMaxBytes) * 100,
199+
diskUtilization: _config.diskMaxBytes > 0
200+
? (diskSize / _config.diskMaxBytes) * 100
201+
: 0,
199202
);
200203
}
201204

@@ -222,6 +225,14 @@ class MxcCacheManager {
222225
void _onCacheUpdated(String mxcUrl, Uint8List newBytes) {
223226
// Update memory cache with fresh content
224227
_memoryTier.put(mxcUrl, newBytes);
228+
// Also update disk tier using fire-and-forget
229+
unawaited(
230+
_diskTier.put(
231+
mxcUrl: mxcUrl,
232+
bytes: newBytes,
233+
mediaType: 'application/octet-stream',
234+
),
235+
);
225236
Logs().d('MxcCacheManager: updated $mxcUrl from background revalidation');
226237
}
227238
}

0 commit comments

Comments
 (0)