π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Improve backup error handling and validation
Prateek Sunale4093cb7052b
diff --git a/mobile/apps/auth/lib/l10n/arb/app_en.arb b/mobile/apps/auth/lib/l10n/arb/app_en.arbindex 3a950b3fb8..85e691f00d 100644--- a/mobile/apps/auth/lib/l10n/arb/app_en.arb+++ b/mobile/apps/auth/lib/l10n/arb/app_en.arb@@ -110,6 +110,7 @@"importTypeEnteEncrypted": "Ente Encrypted export","passwordForDecryptingExport": "Password to decrypt export","passwordEmptyError": "Password can not be empty",+ "passwordTooShort": "Password must be at least 8 characters","importFromApp": "Import codes from {appName}","importGoogleAuthGuide": "Export your accounts from Google Authenticator to a QR code using the \"Transfer Accounts\" option. Then using another device, scan the QR code.\n\nTip: You can use your laptop's webcam to take a picture of the QR code.","importSelectJsonFile": "Select JSON file",diff --git a/mobile/apps/auth/lib/services/local_backup_service.dart b/mobile/apps/auth/lib/services/local_backup_service.dartindex 23410dfa21..2b940b4bad 100644--- a/mobile/apps/auth/lib/services/local_backup_service.dart+++ b/mobile/apps/auth/lib/services/local_backup_service.dart@@ -51,6 +51,10 @@ class LocalBackupService {}return writeSuccess;} catch (e, s) {+ if (isManual) {+ _logger.severe('Manual backup failed', e, s);+ rethrow;+ }_logger.severe('Silent error during automatic backup', e, s);return false;}@@ -117,9 +121,14 @@ class LocalBackupService {.map((entity) => entity as File).toList();- files.sort(- (a, b) => a.lastModifiedSync().compareTo(b.lastModifiedSync()),- );+ files.sort((a, b) {+ final mtimeCompare =+ a.lastModifiedSync().compareTo(b.lastModifiedSync());+ if (mtimeCompare != 0) {+ return mtimeCompare;+ }+ return a.path.compareTo(b.path);+ });while (files.length > _maxBackups) {final fileToDelete = files.removeAt(0);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 722938ccef..a28e19b205 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@@ -171,7 +171,18 @@ class _LocalBackupExperienceState extends State<LocalBackupExperience> {final hasLocation = await _ensureBackupLocationSelected();if (!hasLocation) return;- await LocalBackupService.instance.triggerAutomaticBackup(isManual: true);+ try {+ final success = await LocalBackupService.instance+ .triggerAutomaticBackup(isManual: true);+ if (!success && showSnackBar) {+ _showSnackBar(context.l10n.somethingWentWrongPleaseTryAgain);+ }+ } catch (_) {+ if (showSnackBar) {+ _showSnackBar(context.l10n.somethingWentWrongPleaseTryAgain);+ }+ return;+ }if (showSnackBar) {_showSnackBar(context.l10n.initialBackupCreated);}@@ -354,34 +365,33 @@ class _LocalBackupExperienceState extends State<LocalBackupExperience> {style: getEnteTextTheme(context).smallFaint,),const SizedBox(height: 12),- TextField(- controller: textController,- autofocus: true,- obscureText: isPasswordHidden,- decoration: InputDecoration(- hintText: l10n.enterPassword,- hintStyle: getEnteTextTheme(context).mini,- suffixIcon: IconButton(- icon: Icon(- isPasswordHidden- ? Icons.visibility_off- : Icons.visibility,- ),- onPressed: () {- setState(() {- isPasswordHidden = !isPasswordHidden;- });- },- ),+ TextField(+ controller: textController,+ autofocus: true,+ obscureText: isPasswordHidden,+ decoration: InputDecoration(+ hintText: l10n.enterPassword,+ hintStyle: getEnteTextTheme(context).mini,+ suffixIcon: IconButton(+ icon: Icon(+ isPasswordHidden+ ? Icons.visibility_off+ : Icons.visibility,),- onChanged: (text) {+ onPressed: () {setState(() {- if (errorText != null && text.length >= 8) {- errorText = null;- }+ isPasswordHidden = !isPasswordHidden;});},),+ errorText: errorText,+ ),+ onChanged: (text) {+ setState(() {+ if (text.length >= 8 && errorText != null) errorText = null;+ });+ },+ ),AnimatedSwitcher(duration: const Duration(milliseconds: 200),child: errorText == null@@ -525,15 +535,19 @@ class _LocalBackupExperienceState extends State<LocalBackupExperience> {return fullPath.substring(root.length);}}- return fullPath;+ return fullPath.split('/').last;}- if (Platform.isIOS) {+ if (Platform.isIOS || Platform.isMacOS) {var simplified = fullPath;const fileScheme = 'file://';if (simplified.startsWith(fileScheme)) {simplified = simplified.substring(fileScheme.length);}+ final homePath = Platform.environment['HOME'];+ if (homePath != null && simplified.startsWith(homePath)) {+ simplified = simplified.replaceFirst(homePath, '~');+ }// iOS often prepends /private when surfacing sandboxed locations.const privatePrefix = '/private';if (simplified.startsWith(privatePrefix)) {