π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add ente_qr iOS pod and prioritize local files in bg uploads
Prateek Sunald7c88ac7bcf5
diff --git a/mobile/apps/photos/ios/Podfile.lock b/mobile/apps/photos/ios/Podfile.lockindex 8896f1c714..34e498dde7 100644--- a/mobile/apps/photos/ios/Podfile.lock+++ b/mobile/apps/photos/ios/Podfile.lock@@ -18,6 +18,8 @@ PODS:- Flutter- ente_photos_rust (0.0.1):- Flutter+ - ente_qr (0.0.1):+ - Flutter- ente_rust (0.0.1):- Flutter- ffmpeg_kit_custom (6.0.3)@@ -271,6 +273,7 @@ DEPENDENCIES:- dart_ui_isolate (from `.symlinks/plugins/dart_ui_isolate/ios`)- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)- ente_photos_rust (from `.symlinks/plugins/ente_photos_rust/ios`)+ - ente_qr (from `.symlinks/plugins/ente_qr/ios`)- ente_rust (from `.symlinks/plugins/ente_rust/ios`)- ffmpeg_kit_flutter (from `.symlinks/plugins/ffmpeg_kit_flutter/ios`)- file_saver (from `.symlinks/plugins/file_saver/ios`)@@ -369,6 +372,8 @@ EXTERNAL SOURCES::path: ".symlinks/plugins/device_info_plus/ios"ente_photos_rust::path: ".symlinks/plugins/ente_photos_rust/ios"+ ente_qr:+ :path: ".symlinks/plugins/ente_qr/ios"ente_rust::path: ".symlinks/plugins/ente_rust/ios"ffmpeg_kit_flutter:@@ -490,6 +495,7 @@ SPEC CHECKSUMS:dart_ui_isolate: 46f6714abe6891313267153ef6f9748d8ecfcab1device_info_plus: 21fcca2080fbcd348be798aa36c3e5ed849eefbeente_photos_rust: 79732f3ba67df7b0fb22089627afb80d692c2b2d+ ente_qr: 2a30f91f9e938c229ebcbc98a6f8f018d1ac665dente_rust: 9c976e3d083f0ce90f31693deb99629b28d8fe4cffmpeg_kit_custom: 682b4f2f1ff1f8abae5a92f6c3540f2441d5be99ffmpeg_kit_flutter: 915b345acc97d4142e8a9a8549d177ff10f043f5diff --git a/mobile/apps/photos/ios/Runner.xcodeproj/project.pbxproj b/mobile/apps/photos/ios/Runner.xcodeproj/project.pbxprojindex 9fbcd71200..ca3d7ec9bc 100644--- a/mobile/apps/photos/ios/Runner.xcodeproj/project.pbxproj+++ b/mobile/apps/photos/ios/Runner.xcodeproj/project.pbxproj@@ -637,6 +637,7 @@"${BUILT_PRODUCTS_DIR}/dart_ui_isolate/dart_ui_isolate.framework","${BUILT_PRODUCTS_DIR}/device_info_plus/device_info_plus.framework","${BUILT_PRODUCTS_DIR}/ente_photos_rust/ente_photos_rust.framework",+ "${BUILT_PRODUCTS_DIR}/ente_qr/ente_qr.framework","${BUILT_PRODUCTS_DIR}/ente_rust/ente_rust.framework","${BUILT_PRODUCTS_DIR}/file_saver/file_saver.framework","${BUILT_PRODUCTS_DIR}/flutter_email_sender/flutter_email_sender.framework",@@ -739,6 +740,7 @@"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/dart_ui_isolate.framework","${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/device_info_plus.framework","${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ente_photos_rust.framework",+ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ente_qr.framework","${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ente_rust.framework","${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/file_saver.framework","${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_email_sender.framework",diff --git a/mobile/apps/photos/lib/services/sync/remote_sync_service.dart b/mobile/apps/photos/lib/services/sync/remote_sync_service.dartindex fb1534e160..952f16d1af 100644--- a/mobile/apps/photos/lib/services/sync/remote_sync_service.dart+++ b/mobile/apps/photos/lib/services/sync/remote_sync_service.dart@@ -4,6 +4,7 @@ import 'dart:math';import 'package:flutter/widgets.dart';import 'package:logging/logging.dart';+import 'package:photo_manager/photo_manager.dart';import 'package:photos/core/configuration.dart';import 'package:photos/core/errors.dart';import 'package:photos/core/event_bus.dart';@@ -17,6 +18,7 @@ import 'package:photos/events/files_updated_event.dart';import 'package:photos/events/force_reload_home_gallery_event.dart';import 'package:photos/events/local_photos_updated_event.dart';import 'package:photos/events/sync_status_update_event.dart';+import 'package:photos/extensions/logger_extension.dart';import 'package:photos/main.dart' show isProcessBg;import 'package:photos/models/device_collection.dart';import 'package:photos/models/file/extensions/file_props.dart';@@ -46,6 +48,7 @@ class RemoteSyncService {final Configuration _config = Configuration.instance;final CollectionsService _collectionsService = CollectionsService.instance;final DiffFetcher _diffFetcher = DiffFetcher();+ final PhotoManagerPlugin _photoManagerPlugin = PhotoManagerPlugin();final LocalFileUpdateService _localFileUpdateService =LocalFileUpdateService.instance;int _completedUploads = 0;@@ -651,7 +654,14 @@ class RemoteSyncService {}final List<Future> futures = [];- for (final file in filesToBeUploaded) {+ var uploadQueue = filesToBeUploaded;+ if (Platform.isIOS &&+ isProcessBg &&+ flagService.enableBgLocalUploadPriority) {+ uploadQueue = await _buildBgUploadQueue(filesToBeUploaded);+ }++ for (final file in uploadQueue) {if (shouldThrottleUpload &&futures.length >= kMaximumPermissibleUploadsInThrottledMode) {break;@@ -1007,6 +1017,79 @@ class RemoteSyncService {});}+ /// Builds an upload queue for iOS background sync. For each upload slot,+ /// checks up to [kMaximumPermissibleUploadsInThrottledMode] candidates to+ /// find one that's locally available (not iCloud-only). If a local file is+ /// found, it's picked; otherwise the next file in line is used.+ /// Files already checked and found to be iCloud-only are tracked to avoid+ /// re-checking.+ Future<List<EnteFile>> _buildBgUploadQueue(List<EnteFile> files) async {+ const maxChecksPerSlot = kMaximumPermissibleUploadsInThrottledMode;+ const slots = kMaximumPermissibleUploadsInThrottledMode;+ final Set<int> picked = {};+ final Set<int> knownICloud = {};+ final List<EnteFile> queue = [];++ for (int slot = 0; slot < slots && picked.length < files.length; slot++) {+ int checks = 0;+ int? fallback;+ bool found = false;++ for (int i = 0; i < files.length; i++) {+ if (picked.contains(i)) continue;++ fallback ??= i;++ if (knownICloud.contains(i)) continue;++ if (checks >= maxChecksPerSlot) break;+ checks++;++ if (await _isOriginLocallyAvailable(files[i])) {+ queue.add(files[i]);+ picked.add(i);+ found = true;+ break;+ } else {+ knownICloud.add(i);+ }+ }++ if (!found && fallback != null) {+ queue.add(files[fallback]);+ picked.add(fallback);+ }+ }++ _logger.internalInfo(+ "Built bg upload queue: ${queue.length} files, "+ "${knownICloud.length} iCloud-only skipped",+ );+ return queue;+ }++ Future<bool> _isOriginLocallyAvailable(EnteFile file) async {+ try {+ if (file.localID == null) {+ return false;+ }+ return await _photoManagerPlugin.isLocallyAvailable(+ file.localID!,+ isOrigin: true,+ subtype: file.fileType == FileType.livePhoto+ ? (file.fileSubType ?? 0)+ : 0,+ );+ } catch (e, s) {+ _logger.warning(+ "Failed to determine local availability for ${file.tag}",+ e,+ s,+ );+ return false;+ }+ }+bool _shouldShowSharedPhotosAndAlbumsNotification(int collectionID) {// TODO: Add option to opt out of notifications for a specific collection// Screen: https://www.figma.com/file/SYtMyLBs5SAOkTbfMMzhqt/ente-Visual-Design?type=design&node-id=7689-52943&t=IyWOfh0Gsb0p7yVC-4diff --git a/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart b/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dartindex 4f1ab63fcc..6b9b10b3df 100644--- a/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart+++ b/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart@@ -104,6 +104,8 @@ class FlagService {bool get qrFeatureEnabled => internalUser;+ bool get enableBgLocalUploadPriority => internalUser;+Future<void> tryRefreshFlags() async {try {await _fetch();