💚 End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
exclude documents and app support dirs from iCloud backup on init
victore8dabdc601ed
diff --git a/mobile/apps/photos/lib/core/configuration.dart b/mobile/apps/photos/lib/core/configuration.dartindex cb57ea528b..65787bdd30 100644--- a/mobile/apps/photos/lib/core/configuration.dart+++ b/mobile/apps/photos/lib/core/configuration.dart@@ -41,6 +41,7 @@ import 'package:photos/services/search_service.dart';import 'package:photos/services/sync/sync_service.dart';import 'package:photos/services/video_preview_service.dart';import 'package:photos/utils/file_uploader.dart';+import 'package:photos/utils/ios_backup_util.dart';import "package:photos/utils/lock_screen_settings.dart";import 'package:photos/utils/validator_util.dart';import 'package:shared_preferences/shared_preferences.dart';@@ -95,6 +96,10 @@ class Configuration {),);_documentsDirectory = (await getApplicationDocumentsDirectory()).path;+ final appSupportDirectory = await getApplicationSupportDirectory();+ // Exclude Documents (SQLite, thumbnails, decrypted media) and Application Support (ML models) from backups since they’re server-derivable or must remain within the device’s E2EE boundary.+ await excludeFromBackup(_documentsDirectory);+ await excludeFromBackup(appSupportDirectory.path);_tempDocumentsDirPath = _documentsDirectory + "/temp/";final tempDocumentsDir = Directory(_tempDocumentsDirPath);await _cleanUpStaleFiles(tempDocumentsDir);diff --git a/mobile/apps/photos/lib/utils/ios_backup_util.dart b/mobile/apps/photos/lib/utils/ios_backup_util.dartindex 781b3cc2b8..034c51d171 100644--- a/mobile/apps/photos/lib/utils/ios_backup_util.dart+++ b/mobile/apps/photos/lib/utils/ios_backup_util.dart@@ -38,5 +38,10 @@ Future<void> _invokeExcludeFromBackup(String path) async {}} on PlatformException catch (e) {_logger.warning('Failed to exclude path from backup: $path — ${e.message}');+ } on MissingPluginException {+ // Channel not registered in headless background execution (Workmanager).+ // Safe to ignore: backup exclusion is a best-effort attribute set on+ // foreground init; background tasks do not trigger iCloud backups.+ _logger.info('excludeFromBackup skipped: channel unavailable (background)');}}diff --git a/mobile/apps/photos/test/utils/ios_backup_util_test.dart b/mobile/apps/photos/test/utils/ios_backup_util_test.dartindex c7733836a7..63786d6b33 100644--- a/mobile/apps/photos/test/utils/ios_backup_util_test.dart+++ b/mobile/apps/photos/test/utils/ios_backup_util_test.dart@@ -79,6 +79,31 @@ void main() {isTrue,);});++ test(+ 'logs info and does not throw when channel is unregistered '+ '(MissingPluginException — headless background)', () async {+ // Remove the mock handler so invokeMethod throws MissingPluginException,+ // simulating headless Workmanager execution where the channel is never+ // registered.+ TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger+ .setMockMethodCallHandler(channel, null);++ final logs = <LogRecord>[];+ final sub = Logger('IosBackupUtil').onRecord.listen(logs.add);++ await expectLater(invokeExcludeFromBackup(testPath), completes);++ await sub.cancel();+ expect(+ logs.any(+ (r) =>+ r.level == Level.INFO &&+ r.message.contains('channel unavailable'),+ ),+ isTrue,+ );+ });});group('excludeFromBackup (platform guard)', () {