π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[auth] restore createDirectory in dir_utils for iOS subdirectory creation
Prateek Sunaled2fa0c80c90
diff --git a/mobile/apps/auth/lib/services/local_backup_service.dart b/mobile/apps/auth/lib/services/local_backup_service.dartindex b78632b5c4..6f160821f6 100644--- a/mobile/apps/auth/lib/services/local_backup_service.dart+++ b/mobile/apps/auth/lib/services/local_backup_service.dart@@ -160,9 +160,15 @@ class LocalBackupService {bookmark: target.iosBookmark,);final result = await dirUtils.withAccess(dir, (path) async {- // Use EnteAuthBackups subdirectory+ // Create EnteAuthBackups subdirectory using native method+ final created = await dirUtils.createDirectory(+ PickedDirectory(path: path),+ 'EnteAuthBackups',+ );+ if (!created) {+ return false;+ }final backupPath = '$path/EnteAuthBackups';- await Directory(backupPath).create(recursive: true);final success = await dirUtils.writeFile(PickedDirectory(path: backupPath),fileName,diff --git a/mobile/apps/auth/lib/ui/settings/data/local_backup/local_backup_experience.dart b/mobile/apps/auth/lib/ui/settings/data/local_backup/local_backup_experience.dartindex 286e1dd6cb..38ce694705 100644--- a/mobile/apps/auth/lib/ui/settings/data/local_backup/local_backup_experience.dart+++ b/mobile/apps/auth/lib/ui/settings/data/local_backup/local_backup_experience.dart@@ -761,11 +761,17 @@ class _LocalBackupExperienceState extends State<LocalBackupExperience> {}try {- // Create EnteAuthBackups subdirectory inside the selected path- final backupDir = Directory('$path/EnteAuthBackups');- await backupDir.create(recursive: true);+ // Create EnteAuthBackups subdirectory using native method for iOS+ final created = await DirUtils.instance.createDirectory(+ PickedDirectory(path: path),+ 'EnteAuthBackups',+ );+ if (!created) {+ _logger.severe('iOS: Failed to create EnteAuthBackups subdirectory');+ return false;+ }await LocalBackupService.instance- .writeBackupToDirectory(backupDir.path);+ .writeBackupToDirectory('$path/EnteAuthBackups');} finally {await SecurityBookmarkService.instance.stopAccessingBookmark(bookmark);}diff --git a/mobile/packages/dir_utils/lib/dir_utils.dart b/mobile/packages/dir_utils/lib/dir_utils.dartindex 7b51093fb0..058c51315d 100644--- a/mobile/packages/dir_utils/lib/dir_utils.dart+++ b/mobile/packages/dir_utils/lib/dir_utils.dart@@ -446,4 +446,41 @@ class DirUtils {return false;}}++ /// Create a subdirectory within a picked directory.+ /// On iOS, this uses the native method channel for security-scoped access.+ Future<bool> createDirectory(PickedDirectory dir, String subPath) async {+ if (Platform.isAndroid && dir.treeUri != null) {+ // SAF creates directories automatically when writing files+ return true;+ } else if (Platform.isIOS && dir.bookmark != null) {+ return _createDirectoryIos(dir, subPath);+ } else {+ return _createDirectoryOther(dir.path, subPath);+ }+ }++ Future<bool> _createDirectoryIos(PickedDirectory dir, String subPath) async {+ try {+ final fullPath = '${dir.path}/$subPath';+ final result = await _channel.invokeMethod<bool>(+ 'createDirectory',+ {'path': fullPath},+ );+ return result ?? false;+ } on PlatformException catch (e) {+ _logger.severe('iOS: Failed to create directory: ${e.message}');+ return false;+ }+ }++ Future<bool> _createDirectoryOther(String basePath, String subPath) async {+ try {+ await Directory('$basePath/$subPath').create(recursive: true);+ return true;+ } catch (e) {+ _logger.severe('Other: Failed to create directory: $e');+ return false;+ }+ }}