π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mobile][photos] merge cache writes for timeline and log into one method to prevent race condition
Priyanshu Dangareb55544432cdb
diff --git a/mobile/apps/photos/lib/services/memory_lane/memory_lane_cache_service.dart b/mobile/apps/photos/lib/services/memory_lane/memory_lane_cache_service.dartindex 2d27e25a61..221645b7b3 100644--- a/mobile/apps/photos/lib/services/memory_lane/memory_lane_cache_service.dart+++ b/mobile/apps/photos/lib/services/memory_lane/memory_lane_cache_service.dart@@ -70,22 +70,16 @@ class MemoryLaneCacheService {return Map<String, MemoryLaneComputeLogEntry>.from(cache.computeLog);}- Future<void> upsertTimeline(MemoryLanePersonTimeline timeline) async {+ Future<void> upsertTimelineAndLog(+ MemoryLanePersonTimeline timeline,+ MemoryLaneComputeLogEntry log,+ ) async {await _ensureInitialized();await _lock.synchronized(() async {final currentCache = await _loadCacheUnsafe();- final updatedCache = currentCache.copyWithTimeline(timeline);- _cache = updatedCache;- await _writeCacheUnsafe();- });- }-- Future<void> upsertComputeLogEntry(MemoryLaneComputeLogEntry entry) async {- await _ensureInitialized();- await _lock.synchronized(() async {- final currentCache = await _loadCacheUnsafe();- final updatedCache = currentCache.copyWithComputeLogEntry(entry);- _cache = updatedCache;+ _cache = currentCache+ .copyWithTimeline(timeline)+ .copyWithComputeLogEntry(log);await _writeCacheUnsafe();});}diff --git a/mobile/apps/photos/lib/services/memory_lane/memory_lane_service.dart b/mobile/apps/photos/lib/services/memory_lane/memory_lane_service.dartindex 5b625cb062..cfdea2ea27 100644--- a/mobile/apps/photos/lib/services/memory_lane/memory_lane_service.dart+++ b/mobile/apps/photos/lib/services/memory_lane/memory_lane_service.dart@@ -552,8 +552,8 @@ class MemoryLaneService {if (request.isRevoked || !identical(_pendingRequests[personId], request)) {return;}- await _cacheService.upsertTimeline(timeline);- await _cacheService.upsertComputeLogEntry(+ await _cacheService.upsertTimelineAndLog(+ timeline,MemoryLaneComputeLogEntry(personId: personId,name: person?.data.name,