π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Move local file updates into upload module
Neeraj Gupta3c742fa46557
diff --git a/mobile/apps/photos/lib/main.dart b/mobile/apps/photos/lib/main.dartindex d7c22c78a0..05cf6b83cb 100644--- a/mobile/apps/photos/lib/main.dart+++ b/mobile/apps/photos/lib/main.dart@@ -39,13 +39,13 @@ import 'package:photos/ente_theme_data.dart';import "package:photos/generated/l10n.dart";import "package:photos/l10n/l10n.dart";import 'package:photos/module/upload/service/file_uploader.dart';+import 'package:photos/module/upload/service/local_file_update_service.dart';import "package:photos/service_locator.dart";import "package:photos/services/account/user_service.dart";import 'package:photos/services/app_lifecycle_service.dart';import 'package:photos/services/collections_service.dart';import 'package:photos/services/favorites_service.dart';import 'package:photos/services/home_widget_service.dart';-import 'package:photos/services/local_file_update_service.dart';import "package:photos/services/machine_learning/face_ml/person/person_service.dart";import 'package:photos/services/machine_learning/ml_service.dart';import 'package:photos/services/machine_learning/semantic_search/semantic_search_service.dart';diff --git a/mobile/apps/photos/lib/services/local_file_update_service.dart b/mobile/apps/photos/lib/module/upload/service/local_file_update_service.dartsimilarity index 93%rename from mobile/apps/photos/lib/services/local_file_update_service.dartrename to mobile/apps/photos/lib/module/upload/service/local_file_update_service.dartindex 7f4c51b8da..82c5d79c4d 100644--- a/mobile/apps/photos/lib/services/local_file_update_service.dart+++ b/mobile/apps/photos/lib/module/upload/service/local_file_update_service.dart@@ -1,5 +1,4 @@import 'dart:async';-import 'dart:core';import 'dart:io';import 'package:ente_pure_utils/ente_pure_utils.dart'@@ -16,14 +15,11 @@ import "package:photos/module/upload/upload_data.dart";import 'package:photos/utils/file_util.dart';import 'package:shared_preferences/shared_preferences.dart';-// LocalFileUpdateService tracks all the potential local file IDs which have-// changed/modified on the device and needed to be uploaded again.+/// Finds device files whose contents changed after upload and queues updates.class LocalFileUpdateService {- late FileUpdationDB _fileUpdationDB;- late SharedPreferences _prefs;- late Logger _logger;+ static final instance = LocalFileUpdateService._privateConstructor();- final List<String> _oldMigrationKeys = [+ static const _oldMigrationKeys = ['fm_badCreationTime','fm_badCreationTimeCompleted','fm_missingLocationV2ImportDone',@@ -37,20 +33,18 @@ class LocalFileUpdateService {'fm_android_missing_gps_check_done',];+ final FileUpdationDB _fileUpdationDB = FileUpdationDB.instance;+ final Logger _logger = Logger("LocalFileUpdateService");+ late SharedPreferences _prefs;+Completer<void>? _existingMigration;- LocalFileUpdateService._privateConstructor() {- _logger = Logger((LocalFileUpdateService).toString());- _fileUpdationDB = FileUpdationDB.instance;- }+ LocalFileUpdateService._privateConstructor();void init(SharedPreferences preferences) {_prefs = preferences;}- static LocalFileUpdateService instance =- LocalFileUpdateService._privateConstructor();-Future<void> markUpdatedFilesForReUpload() async {if (_existingMigration != null) {_logger.info("migration is already in progress, skipping");@@ -206,7 +200,7 @@ class LocalFileUpdateService {processedIDs.add(file.localID!);} catch (e, s) {_logger.severe("Failed to check hash", e, s);- } finally {}+ }}await _fileUpdationDB.deleteByLocalIDs(processedIDs.toList(),diff --git a/mobile/apps/photos/lib/services/sync/remote_sync_service.dart b/mobile/apps/photos/lib/services/sync/remote_sync_service.dartindex 94111d5da4..1fd60f86a9 100644--- a/mobile/apps/photos/lib/services/sync/remote_sync_service.dart+++ b/mobile/apps/photos/lib/services/sync/remote_sync_service.dart@@ -26,13 +26,13 @@ import 'package:photos/models/file/file.dart';import 'package:photos/models/file/file_type.dart';import 'package:photos/models/upload_strategy.dart';import 'package:photos/module/upload/service/file_uploader.dart';+import 'package:photos/module/upload/service/local_file_update_service.dart';import 'package:photos/service_locator.dart';import 'package:photos/services/app_lifecycle_service.dart';import 'package:photos/services/collections_service.dart';import 'package:photos/services/hidden_service.dart';import 'package:photos/services/ignored_files_service.dart';import 'package:photos/services/language_service.dart';-import 'package:photos/services/local_file_update_service.dart';import 'package:photos/services/notification_service.dart';import 'package:photos/services/social_notification_coordinator.dart';import 'package:photos/services/social_sync_service.dart';