Skip to content

armgit / ente

Public Imported from GitHub
0

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

Extract iOS backup exclusion into shared package

Neeraj Gupta66976d1d4213
diff --git a/mobile/apps/photos/ios/Podfile.lock b/mobile/apps/photos/ios/Podfile.lock
index 34e498dde7..e274a96f45 100644
--- a/mobile/apps/photos/ios/Podfile.lock
+++ b/mobile/apps/photos/ios/Podfile.lock
@@ -3,6 +3,8 @@ PODS:
- Flutter
- audio_session (0.0.1):
- Flutter
+ - backup_exclusion (1.0.0):
+ - Flutter
- battery_info (0.0.1):
- Flutter
- camera_avfoundation (0.0.1):
@@ -266,6 +268,7 @@ PODS:
DEPENDENCIES:
- app_links (from `.symlinks/plugins/app_links/ios`)
- audio_session (from `.symlinks/plugins/audio_session/ios`)
+ - backup_exclusion (from `.symlinks/plugins/backup_exclusion/ios`)
- battery_info (from `.symlinks/plugins/battery_info/ios`)
- camera_avfoundation (from `.symlinks/plugins/camera_avfoundation/ios`)
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
@@ -358,6 +361,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/app_links/ios"
audio_session:
:path: ".symlinks/plugins/audio_session/ios"
+ backup_exclusion:
+ :path: ".symlinks/plugins/backup_exclusion/ios"
battery_info:
:path: ".symlinks/plugins/battery_info/ios"
camera_avfoundation:
@@ -488,6 +493,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
app_links: 76b66b60cc809390ca1ad69bfd66b998d2387ac7
audio_session: 9bb7f6c970f21241b19f5a3658097ae459681ba0
+ backup_exclusion: 70e8847af915e95b2ff3323c6f49be001075353a
battery_info: 83f3aae7be2fccefab1d2bf06b8aa96f11c8bcdd
camera_avfoundation: be3be85408cd4126f250386828e9b1dfa40ab436
connectivity_plus: cb623214f4e1f6ef8fe7403d580fdad517d2f7dd
diff --git a/mobile/apps/photos/ios/Runner.xcodeproj/project.pbxproj b/mobile/apps/photos/ios/Runner.xcodeproj/project.pbxproj
index ca3d7ec9bc..6ebd9eeb8c 100644
--- a/mobile/apps/photos/ios/Runner.xcodeproj/project.pbxproj
+++ b/mobile/apps/photos/ios/Runner.xcodeproj/project.pbxproj
@@ -630,6 +630,7 @@
"${BUILT_PRODUCTS_DIR}/Sentry/Sentry.framework",
"${BUILT_PRODUCTS_DIR}/app_links/app_links.framework",
"${BUILT_PRODUCTS_DIR}/audio_session/audio_session.framework",
+ "${BUILT_PRODUCTS_DIR}/backup_exclusion/backup_exclusion.framework",
"${BUILT_PRODUCTS_DIR}/battery_info/battery_info.framework",
"${BUILT_PRODUCTS_DIR}/camera_avfoundation/camera_avfoundation.framework",
"${BUILT_PRODUCTS_DIR}/connectivity_plus/connectivity_plus.framework",
@@ -733,6 +734,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Sentry.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/app_links.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/audio_session.framework",
+ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/backup_exclusion.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/battery_info.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/camera_avfoundation.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/connectivity_plus.framework",
diff --git a/mobile/apps/photos/ios/Runner/AppDelegate.swift b/mobile/apps/photos/ios/Runner/AppDelegate.swift
index 60579b3ca4..16ead278f0 100644
--- a/mobile/apps/photos/ios/Runner/AppDelegate.swift
+++ b/mobile/apps/photos/ios/Runner/AppDelegate.swift
@@ -32,7 +32,6 @@ import workmanager_apple
}
GeneratedPluginRegistrant.register(with: self)
- registerBackupExclusionChannel()
WorkmanagerPlugin.setPluginRegistrantCallback { registry in
GeneratedPluginRegistrant.register(with: registry)
}
@@ -85,38 +84,6 @@ import workmanager_apple
return json["internalUser"] as? Bool ?? false
}
- private func registerBackupExclusionChannel() {
- guard let controller = window?.rootViewController as? FlutterViewController else {
- NSLog("[ente] registerBackupExclusionChannel: no FlutterViewController found, backup exclusion will not be applied")
- return
- }
- let channel = FlutterMethodChannel(
- name: "io.ente.photos/backup",
- binaryMessenger: controller.binaryMessenger)
- channel.setMethodCallHandler { call, result in
- guard call.method == "excludeFromBackup" else {
- result(FlutterMethodNotImplemented)
- return
- }
- guard let args = call.arguments as? [String: Any],
- let path = args["path"] as? String
- else {
- result(FlutterError(code: "INVALID_ARGS", message: "Missing 'path'", details: nil))
- return
- }
- var url = URL(fileURLWithPath: path)
- do {
- try url.setResourceValue(true, forKey: .isExcludedFromBackupKey)
- result(true)
- } catch {
- result(FlutterError(
- code: "EXCLUDE_BACKUP_ERROR",
- message: error.localizedDescription,
- details: nil))
- }
- }
- }
-
override func applicationDidBecomeActive(_ application: UIApplication) {
signal(SIGPIPE, SIG_IGN)
}
diff --git a/mobile/apps/photos/lib/core/configuration.dart b/mobile/apps/photos/lib/core/configuration.dart
index 65787bdd30..e0dc705cae 100644
--- a/mobile/apps/photos/lib/core/configuration.dart
+++ b/mobile/apps/photos/lib/core/configuration.dart
@@ -2,6 +2,7 @@ import "dart:async";
import 'dart:convert';
import "dart:io";
+import 'package:backup_exclusion/backup_exclusion.dart';
import 'package:bip39/bip39.dart' as bip39;
import "package:ente_crypto/ente_crypto.dart";
import "package:flutter/services.dart";
@@ -41,7 +42,6 @@ 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';
diff --git a/mobile/apps/photos/pubspec.lock b/mobile/apps/photos/pubspec.lock
index 5a5e9677c5..b1019f5d36 100644
--- a/mobile/apps/photos/pubspec.lock
+++ b/mobile/apps/photos/pubspec.lock
@@ -137,6 +137,13 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.2.2"
+ backup_exclusion:
+ dependency: "direct main"
+ description:
+ path: "../../packages/backup_exclusion"
+ relative: true
+ source: path
+ version: "1.0.0"
battery_info:
dependency: "direct main"
description:
diff --git a/mobile/apps/photos/pubspec.yaml b/mobile/apps/photos/pubspec.yaml
index 00a66bd9a8..3d5c01f20e 100644
--- a/mobile/apps/photos/pubspec.yaml
+++ b/mobile/apps/photos/pubspec.yaml
@@ -26,6 +26,8 @@ dependencies:
archive: ^4.0.7
async: ^2.11.0
audio_session: ^0.2.2
+ backup_exclusion:
+ path: ../../packages/backup_exclusion
battery_info: # replace with battery_plus
git:
url: https://github.com/ente-io/battery_info
diff --git a/mobile/packages/backup_exclusion/.gitignore b/mobile/packages/backup_exclusion/.gitignore
new file mode 100644
index 0000000000..567609b123
--- /dev/null
+++ b/mobile/packages/backup_exclusion/.gitignore
@@ -0,0 +1 @@
+build/
diff --git a/mobile/packages/backup_exclusion/ios/Classes/BackupExclusionPlugin.swift b/mobile/packages/backup_exclusion/ios/Classes/BackupExclusionPlugin.swift
new file mode 100644
index 0000000000..8546bd4641
--- /dev/null
+++ b/mobile/packages/backup_exclusion/ios/Classes/BackupExclusionPlugin.swift
@@ -0,0 +1,38 @@
+import Flutter
+import Foundation
+
+public class BackupExclusionPlugin: NSObject, FlutterPlugin {
+ public static func register(with registrar: FlutterPluginRegistrar) {
+ let channel = FlutterMethodChannel(
+ name: "io.ente.backup_exclusion",
+ binaryMessenger: registrar.messenger()
+ )
+ let instance = BackupExclusionPlugin()
+ registrar.addMethodCallDelegate(instance, channel: channel)
+ }
+
+ public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
+ guard call.method == "excludeFromBackup" else {
+ result(FlutterMethodNotImplemented)
+ return
+ }
+
+ guard let args = call.arguments as? [String: Any],
+ let path = args["path"] as? String else {
+ result(FlutterError(code: "INVALID_ARGS", message: "Missing 'path'", details: nil))
+ return
+ }
+
+ let url = NSURL(fileURLWithPath: path)
+ do {
+ try url.setResourceValue(true, forKey: URLResourceKey.isExcludedFromBackupKey)
+ result(true)
+ } catch {
+ result(FlutterError(
+ code: "EXCLUDE_BACKUP_ERROR",
+ message: error.localizedDescription,
+ details: nil
+ ))
+ }
+ }
+}
diff --git a/mobile/packages/backup_exclusion/ios/backup_exclusion.podspec b/mobile/packages/backup_exclusion/ios/backup_exclusion.podspec
new file mode 100644
index 0000000000..de872dd7a3
--- /dev/null
+++ b/mobile/packages/backup_exclusion/ios/backup_exclusion.podspec
@@ -0,0 +1,19 @@
+Pod::Spec.new do |s|
+ s.name = 'backup_exclusion'
+ s.version = '1.0.0'
+ s.summary = 'Exclude app-managed files from iOS backups'
+ s.description = <<-DESC
+Marks app-managed files and directories as excluded from iCloud and local
+device backups.
+ DESC
+ s.homepage = 'https://github.com/ente-io/ente'
+ s.license = { :file => '../LICENSE' }
+ s.author = { 'Ente' => '[email protected]' }
+ s.source = { :path => '.' }
+ s.source_files = 'Classes/**/*'
+ s.dependency 'Flutter'
+ s.platform = :ios, '13.0'
+ s.swift_version = '5.0'
+
+ s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
+end
diff --git a/mobile/apps/photos/lib/utils/ios_backup_util.dart b/mobile/packages/backup_exclusion/lib/backup_exclusion.dart
similarity index 83%
rename from mobile/apps/photos/lib/utils/ios_backup_util.dart
rename to mobile/packages/backup_exclusion/lib/backup_exclusion.dart
index 034c51d171..5a347aa655 100644
--- a/mobile/apps/photos/lib/utils/ios_backup_util.dart
+++ b/mobile/packages/backup_exclusion/lib/backup_exclusion.dart
@@ -4,8 +4,8 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:logging/logging.dart';
-final _logger = Logger('IosBackupUtil');
-const _channel = MethodChannel('io.ente.photos/backup');
+final _logger = Logger('BackupExclusion');
+const _channel = MethodChannel('io.ente.backup_exclusion');
/// Marks [path] as excluded from iCloud and local backups on iOS.
///
@@ -29,15 +29,14 @@ Future<void> invokeExcludeFromBackup(String path) =>
Future<void> _invokeExcludeFromBackup(String path) async {
try {
- final ok = await _channel.invokeMethod<bool>(
- 'excludeFromBackup',
- {'path': path},
- );
+ final ok = await _channel.invokeMethod<bool>('excludeFromBackup', {
+ 'path': path,
+ });
if (ok != true) {
_logger.warning('excludeFromBackup returned false for: $path');
}
} on PlatformException catch (e) {
- _logger.warning('Failed to exclude path from backup: $path β€” ${e.message}');
+ _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
diff --git a/mobile/packages/backup_exclusion/pubspec.lock b/mobile/packages/backup_exclusion/pubspec.lock
new file mode 100644
index 0000000000..49bd1f9212
--- /dev/null
+++ b/mobile/packages/backup_exclusion/pubspec.lock
@@ -0,0 +1,213 @@
+# Generated by pub
+# See https://dart.dev/tools/pub/glossary#lockfile
+packages:
+ async:
+ dependency: transitive
+ description:
+ name: async
+ sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.13.0"
+ boolean_selector:
+ dependency: transitive
+ description:
+ name: boolean_selector
+ sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.1.2"
+ characters:
+ dependency: transitive
+ description:
+ name: characters
+ sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.4.0"
+ clock:
+ dependency: transitive
+ description:
+ name: clock
+ sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.1.2"
+ collection:
+ dependency: transitive
+ description:
+ name: collection
+ sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.19.1"
+ fake_async:
+ dependency: transitive
+ description:
+ name: fake_async
+ sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.3.3"
+ flutter:
+ dependency: "direct main"
+ description: flutter
+ source: sdk
+ version: "0.0.0"
+ flutter_lints:
+ dependency: "direct dev"
+ description:
+ name: flutter_lints
+ sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.0.3"
+ flutter_test:
+ dependency: "direct dev"
+ description: flutter
+ source: sdk
+ version: "0.0.0"
+ leak_tracker:
+ dependency: transitive
+ description:
+ name: leak_tracker
+ sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0"
+ url: "https://pub.dev"
+ source: hosted
+ version: "10.0.9"
+ leak_tracker_flutter_testing:
+ dependency: transitive
+ description:
+ name: leak_tracker_flutter_testing
+ sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.0.9"
+ leak_tracker_testing:
+ dependency: transitive
+ description:
+ name: leak_tracker_testing
+ sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.0.1"
+ lints:
+ dependency: transitive
+ description:
+ name: lints
+ sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.1.1"
+ logging:
+ dependency: "direct main"
+ description:
+ name: logging
+ sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.3.0"
+ matcher:
+ dependency: transitive
+ description:
+ name: matcher
+ sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.12.17"
+ material_color_utilities:
+ dependency: transitive
+ description:
+ name: material_color_utilities
+ sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.11.1"
+ meta:
+ dependency: transitive
+ description:
+ name: meta
+ sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.16.0"
+ path:
+ dependency: transitive
+ description:
+ name: path
+ sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.9.1"
+ sky_engine:
+ dependency: transitive
+ description: flutter
+ source: sdk
+ version: "0.0.0"
+ source_span:
+ dependency: transitive
+ description:
+ name: source_span
+ sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.10.1"
+ stack_trace:
+ dependency: transitive
+ description:
+ name: stack_trace
+ sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.12.1"
+ stream_channel:
+ dependency: transitive
+ description:
+ name: stream_channel
+ sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.1.4"
+ string_scanner:
+ dependency: transitive
+ description:
+ name: string_scanner
+ sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.4.1"
+ term_glyph:
+ dependency: transitive
+ description:
+ name: term_glyph
+ sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.2.2"
+ test_api:
+ dependency: transitive
+ description:
+ name: test_api
+ sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.7.4"
+ vector_math:
+ dependency: transitive
+ description:
+ name: vector_math
+ sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.1.4"
+ vm_service:
+ dependency: transitive
+ description:
+ name: vm_service
+ sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02
+ url: "https://pub.dev"
+ source: hosted
+ version: "15.0.0"
+sdks:
+ dart: ">=3.7.0-0 <4.0.0"
+ flutter: ">=3.18.0-18.0.pre.54"
diff --git a/mobile/packages/backup_exclusion/pubspec.yaml b/mobile/packages/backup_exclusion/pubspec.yaml
new file mode 100644
index 0000000000..e906ef76d1
--- /dev/null
+++ b/mobile/packages/backup_exclusion/pubspec.yaml
@@ -0,0 +1,25 @@
+name: backup_exclusion
+description: iOS backup exclusion utilities for Ente Flutter apps
+version: 1.0.0
+homepage: https://github.com/ente-io/ente
+publish_to: none
+
+environment:
+ sdk: ">=3.0.0 <4.0.0"
+ flutter: ">=2.5.0"
+
+dependencies:
+ flutter:
+ sdk: flutter
+ logging: ^1.2.0
+
+dev_dependencies:
+ flutter_lints: ^2.0.0
+ flutter_test:
+ sdk: flutter
+
+flutter:
+ plugin:
+ platforms:
+ ios:
+ pluginClass: BackupExclusionPlugin
diff --git a/mobile/apps/photos/test/utils/ios_backup_util_test.dart b/mobile/packages/backup_exclusion/test/backup_exclusion_test.dart
similarity index 66%
rename from mobile/apps/photos/test/utils/ios_backup_util_test.dart
rename to mobile/packages/backup_exclusion/test/backup_exclusion_test.dart
index 63786d6b33..d962ce5ee7 100644
--- a/mobile/apps/photos/test/utils/ios_backup_util_test.dart
+++ b/mobile/packages/backup_exclusion/test/backup_exclusion_test.dart
@@ -1,12 +1,12 @@
+import 'package:backup_exclusion/backup_exclusion.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:logging/logging.dart';
-import 'package:photos/utils/ios_backup_util.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
- const channel = MethodChannel('io.ente.photos/backup');
+ const channel = MethodChannel('io.ente.backup_exclusion');
const testPath = '/var/mobile/Containers/Data/Application/test/Documents';
late List<MethodCall> calls;
@@ -15,9 +15,9 @@ void main() {
calls = [];
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(channel, (call) async {
- calls.add(call);
- return true;
- });
+ calls.add(call);
+ return true;
+ });
});
tearDown(() {
@@ -26,21 +26,23 @@ void main() {
});
group('invokeExcludeFromBackup', () {
- test('invokes excludeFromBackup on the correct channel with the given path',
- () async {
- await invokeExcludeFromBackup(testPath);
+ test(
+ 'invokes excludeFromBackup on the correct channel with the given path',
+ () async {
+ await invokeExcludeFromBackup(testPath);
- expect(calls, hasLength(1));
- expect(calls.first.method, 'excludeFromBackup');
- expect(calls.first.arguments, {'path': testPath});
- });
+ expect(calls, hasLength(1));
+ expect(calls.first.method, 'excludeFromBackup');
+ expect(calls.first.arguments, {'path': testPath});
+ },
+ );
test('logs a warning when the channel returns false', () async {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(channel, (_) async => false);
final logs = <LogRecord>[];
- final sub = Logger('IosBackupUtil').onRecord.listen(logs.add);
+ final sub = Logger('BackupExclusion').onRecord.listen(logs.add);
await invokeExcludeFromBackup(testPath);
@@ -58,14 +60,14 @@ void main() {
test('logs a warning when the channel throws PlatformException', () async {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(channel, (_) async {
- throw PlatformException(
- code: 'EXCLUDE_BACKUP_ERROR',
- message: 'simulated native failure',
- );
- });
+ throw PlatformException(
+ code: 'EXCLUDE_BACKUP_ERROR',
+ message: 'simulated native failure',
+ );
+ });
final logs = <LogRecord>[];
- final sub = Logger('IosBackupUtil').onRecord.listen(logs.add);
+ final sub = Logger('BackupExclusion').onRecord.listen(logs.add);
await invokeExcludeFromBackup(testPath);
@@ -80,17 +82,13 @@ void main() {
);
});
- 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.
+ test('logs info and does not throw when channel is unregistered '
+ '(MissingPluginException - headless background)', () async {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(channel, null);
final logs = <LogRecord>[];
- final sub = Logger('IosBackupUtil').onRecord.listen(logs.add);
+ final sub = Logger('BackupExclusion').onRecord.listen(logs.add);
await expectLater(invokeExcludeFromBackup(testPath), completes);
@@ -108,7 +106,6 @@ void main() {
group('excludeFromBackup (platform guard)', () {
test('does not invoke the channel on non-iOS platforms', () async {
- // Test host is Linux/macOS β€” Platform.isIOS is always false here.
await excludeFromBackup(testPath);
expect(calls, isEmpty);
});