Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

properly clear isolate cache

laurenspriem939d1a5d4097
diff --git a/mobile/lib/services/isolate_functions.dart b/mobile/lib/services/isolate_functions.dart
index ac0817f423..929790c588 100644
--- a/mobile/lib/services/isolate_functions.dart
+++ b/mobile/lib/services/isolate_functions.dart
@@ -47,6 +47,7 @@ enum IsolateOperation {
/// Cache operations
setIsolateCache,
clearIsolateCache,
+ clearAllIsolateCache,
}
/// WARNING: Only return primitives unless you know the method is only going
@@ -181,6 +182,11 @@ Future<dynamic> isolateFunction(
_isolateCache.remove(key);
return true;
+ /// Caching
+ case IsolateOperation.clearAllIsolateCache:
+ _isolateCache.clear();
+ return true;
+
/// Cases for Caching stop here
}
}
diff --git a/mobile/lib/services/isolate_service.dart b/mobile/lib/services/isolate_service.dart
index 24f9f63101..4a91c64473 100644
--- a/mobile/lib/services/isolate_service.dart
+++ b/mobile/lib/services/isolate_service.dart
@@ -165,6 +165,10 @@ abstract class SuperIsolate {
});
}
+ Future<void> clearAllCachedData() async {
+ await runInIsolate(IsolateOperation.clearAllIsolateCache, {});
+ }
+
/// Resets a timer that kills the isolate after a certain amount of inactivity.
///
/// Should be called after initialization (e.g. inside `init()`) and after every call to isolate (e.g. inside `_runInIsolate()`)
@@ -189,7 +193,7 @@ abstract class SuperIsolate {
void _disposeIsolate() async {
if (!_isIsolateSpawned) return;
logger.info('Disposing isolate');
- // await clearAllCachedData();
+ await clearAllCachedData();
await onDispose();
_isIsolateSpawned = false;
_isolate.kill();