π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Handle locker file limit errors
ashilkn81758b66fa00
diff --git a/mobile/apps/locker/lib/core/errors.dart b/mobile/apps/locker/lib/core/errors.dartindex 8391574b5a..13f4dcf015 100644--- a/mobile/apps/locker/lib/core/errors.dart+++ b/mobile/apps/locker/lib/core/errors.dart@@ -10,6 +10,8 @@ class StorageLimitExceededError extends Error {}class NoActiveSubscriptionError extends Error {}+class FileLimitReachedError extends Error {}+// error when file size + current usage >= storage plan limit + bufferclass FileTooLargeForPlanError extends Error {}diff --git a/mobile/apps/locker/lib/l10n/app_en.arb b/mobile/apps/locker/lib/l10n/app_en.arbindex e60eaf1dd2..c716764f2e 100644--- a/mobile/apps/locker/lib/l10n/app_en.arb+++ b/mobile/apps/locker/lib/l10n/app_en.arb@@ -602,6 +602,14 @@"@uploadStorageLimitErrorBody": {"description": "Body shown when uploads fail due to running out of storage"},+ "uploadFileCountLimitErrorTitle": "File limit reached",+ "@uploadFileCountLimitErrorTitle": {+ "description": "Title shown when uploads fail because the locker already has the maximum file count"+ },+ "uploadFileCountLimitErrorBody": "Your individual or family account has hit the 1000-file limit.",+ "@uploadFileCountLimitErrorBody": {+ "description": "Body shown when uploads fail because the locker already has the maximum file count"+ },"uploadFileTooLargeErrorTitle": "File too large","@uploadFileTooLargeErrorTitle": {"description": "Title shown when uploads fail because the file exceeds the supported size"diff --git a/mobile/apps/locker/lib/l10n/app_localizations.dart b/mobile/apps/locker/lib/l10n/app_localizations.dartindex 95da2ca0f2..6ea0e937c2 100644--- a/mobile/apps/locker/lib/l10n/app_localizations.dart+++ b/mobile/apps/locker/lib/l10n/app_localizations.dart@@ -703,7 +703,7 @@ abstract class AppLocalizations {/// No description provided for @shareThisLink.////// In en, this message translates to:- /// **'Anyone with this link can access your item.'**+ /// **'This link allows anyone who receives it to access your item. You can remove access at any time by deleting the link.'**String get shareThisLink;/// No description provided for @copyLink.@@ -2026,6 +2026,18 @@ abstract class AppLocalizations {/// **'You\'ve run out of storage space. Free up space to continue uploading.'**String get uploadStorageLimitErrorBody;+ /// Title shown when uploads fail because the locker already has the maximum file count+ ///+ /// In en, this message translates to:+ /// **'File limit reached'**+ String get uploadFileCountLimitErrorTitle;++ /// Body shown when uploads fail because the locker already has the maximum file count+ ///+ /// In en, this message translates to:+ /// **'Your individual or family account has hit the 1000-file limit.'**+ String get uploadFileCountLimitErrorBody;+/// Title shown when uploads fail because the file exceeds the supported size////// In en, this message translates to:diff --git a/mobile/apps/locker/lib/l10n/app_localizations_en.dart b/mobile/apps/locker/lib/l10n/app_localizations_en.dartindex dd3f2282b2..5b427aa5e2 100644--- a/mobile/apps/locker/lib/l10n/app_localizations_en.dart+++ b/mobile/apps/locker/lib/l10n/app_localizations_en.dart@@ -372,7 +372,8 @@ class AppLocalizationsEn extends AppLocalizations {String get creatingShareLink => 'Creating link...';@override- String get shareThisLink => 'Anyone with this link can access your item.';+ String get shareThisLink =>+ 'This link allows anyone who receives it to access your item. You can remove access at any time by deleting the link.';@overrideString get copyLink => 'Copy link';@@ -1135,6 +1136,13 @@ class AppLocalizationsEn extends AppLocalizations {String get uploadStorageLimitErrorBody =>'You\'ve run out of storage space. Free up space to continue uploading.';+ @override+ String get uploadFileCountLimitErrorTitle => 'File limit reached';++ @override+ String get uploadFileCountLimitErrorBody =>+ 'Your individual or family account has hit the 1000-file limit.';+@overrideString get uploadFileTooLargeErrorTitle => 'File too large';diff --git a/mobile/apps/locker/lib/services/files/upload/file_upload_service.dart b/mobile/apps/locker/lib/services/files/upload/file_upload_service.dartindex d88e98cf20..66bae5c60a 100644--- a/mobile/apps/locker/lib/services/files/upload/file_upload_service.dart+++ b/mobile/apps/locker/lib/services/files/upload/file_upload_service.dart@@ -621,7 +621,9 @@ class FileUploader {return file;} on DioException catch (e) {final int statusCode = e.response?.statusCode ?? -1;- if (statusCode == 413) {+ if (_isFileLimitReachedResponse(e.response)) {+ throw FileLimitReachedError();+ } else if (statusCode == 413) {throw FileTooLargeForPlanError();} else if (statusCode == 426) {_onStorageLimitExceeded();@@ -688,6 +690,19 @@ class FileUploader {}}+ bool _isFileLimitReachedResponse(Response? response) {+ if (response?.statusCode == 403) {+ final dynamic data = response?.data;+ if (data is Map) {+ final code = data['code'];+ if (code is String) {+ return code.toUpperCase() == 'FILE_LIMIT_REACHED';+ }+ }+ }+ return false;+ }+void _onStorageLimitExceeded() {clearQueue(StorageLimitExceededError());throw StorageLimitExceededError();diff --git a/mobile/apps/locker/lib/ui/pages/uploader_page.dart b/mobile/apps/locker/lib/ui/pages/uploader_page.dartindex b9197c58b0..27af8e5917 100644--- a/mobile/apps/locker/lib/ui/pages/uploader_page.dart+++ b/mobile/apps/locker/lib/ui/pages/uploader_page.dart@@ -167,6 +167,13 @@ abstract class UploaderPageState<T extends UploaderPage> extends State<T> {context.l10n.uploadStorageLimitErrorBody,isDismissable: true,);+ } else if (e is FileLimitReachedError) {+ await showErrorDialog(+ context,+ context.l10n.uploadFileCountLimitErrorTitle,+ context.l10n.uploadFileCountLimitErrorBody,+ isDismissable: true,+ );} else if (e is FileTooLargeForPlanError) {await showErrorDialog(context,