π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Retry deleting local files in batches with smaller max batch sizes if no files are deleted with a bigger max batch size
ashilkn93e26c6caf28
diff --git a/mobile/lib/utils/delete_file_util.dart b/mobile/lib/utils/delete_file_util.dartindex 57ecd9ac6e..9537e3606e 100644--- a/mobile/lib/utils/delete_file_util.dart+++ b/mobile/lib/utils/delete_file_util.dart@@ -355,18 +355,10 @@ Future<bool> deleteLocalFiles(// batches. Similar in Android, for large number of files, we have observed// that the library fails to delete any file. So, we initiate deletion in// batches.- if (deletedIDs.isEmpty) {+ if (deletedIDs.isEmpty && Platform.isIOS) {deletedIDs.addAll(- await deleteLocalFilesInBatches(- context,- localAssetIDs,- maximumBatchSize: 1000,- minimumBatchSize: 10,- ),+ await _iosDeleteLocalFilesInBatchesFallback(context, localAssetIDs),);- _logger- .severe("iOS free-space fallback, deleted ${deletedIDs.length} files "- "in batches}");}if (deletedIDs.isNotEmpty) {@@ -656,3 +648,35 @@ Future<void> showDeleteSheet(selectedFiles.clearAll();}}++Future<List<String>> _iosDeleteLocalFilesInBatchesFallback(+ BuildContext context,+ List<String> localAssetIDs,+) async {+ int maximumBatchSize = 1000;+ final List<String> deletedIDs = [];+ do {+ _logger.info(+ "Trying to delete local files in batches with maximumBatchSize: $maximumBatchSize",+ );+ deletedIDs.addAll(+ await deleteLocalFilesInBatches(+ context,+ localAssetIDs,+ maximumBatchSize: maximumBatchSize,+ minimumBatchSize: 10,+ ),+ );+ if (deletedIDs.isEmpty) {+ _logger.warning(+ "Failed to delete local files in batchs with maximumBatchSize: $maximumBatchSize",+ );+ }+ maximumBatchSize = max((maximumBatchSize ~/ 2), 10);+ } while (deletedIDs.isEmpty && maximumBatchSize >= 10);++ _logger.severe("iOS free-space fallback, deleted ${deletedIDs.length} files "+ "in batches}");++ return deletedIDs;+}