From a2be4f88a717f37e54cea943d00d3572f33f3d90 Mon Sep 17 00:00:00 2001 From: vishnukvmd Date: Wed, 5 Jan 2022 13:26:44 +0530 Subject: [PATCH] Throttle log statements to prevent crash --- lib/services/deduplication_service.dart | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/services/deduplication_service.dart b/lib/services/deduplication_service.dart index 339734873..a569e6138 100644 --- a/lib/services/deduplication_service.dart +++ b/lib/services/deduplication_service.dart @@ -34,6 +34,7 @@ class DeduplicationService { List _filterDuplicatesByCreationTime( DuplicateFilesResponse dupes, Map fileMap) { final result = []; + final missingFileIDs = []; for (final dupe in dupes.duplicates) { final files = []; final Map creationTimeCounter = {}; @@ -55,10 +56,7 @@ class DeduplicationService { } files.add(file); } else { - _logger.severe( - "Missing file", - InvalidStateError( - "Could not find file in local DB " + id.toString())); + missingFileIDs.add(id); } } // Ignores those files that were not created within the most common creationTime @@ -83,6 +81,14 @@ class DeduplicationService { result.add(DuplicateFiles(files, dupe.size)); } } + if (missingFileIDs.isNotEmpty) { + _logger.severe( + "Missing files", + InvalidStateError("Could not find " + + missingFileIDs.length.toString() + + " files in local DB: " + + missingFileIDs.toString())); + } return result; }